data_source
stringclasses
1 value
prompt
listlengths
2
2
ability
stringclasses
1 value
reward_model
dict
extra_info
dict
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['M', 'S']\n Gender text, -- example: ['F', 'M']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n BillToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmale refers to Gender = 'M'; female refers to Gender = 'F'; difference in average rate = DIVIDE(AVG(Rate where Gender = 'F')), (AVG(Rate where Gender = 'M'))) as diff;\nCompare the average pay rate of male and female employees.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID GROUP BY T1.Gender", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID GROUP BY T1.Gender", "index": 3400, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['M', 'S']\n Gender text, -- example: ['F', 'M']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n BillToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmale refers to Gender = 'M'; female refers to Gender = 'F'; difference in average rate = DIVIDE(AVG(Rate where Gender = 'F')), (AVG(Rate where Gender = 'M'))) as diff;\nCompare the average pay rate of male and female employees.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['M', 'S']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['M', 'J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n CustomerID integer, -- example: [29825, 29672]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['M', 'A', 'B']\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmarried refers to MaritalStatus = 'M'; male refers to Gender = 'M'; BirthDate < = '1959-12-31';\nHow many married male employees were born before the year 1960?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(BusinessEntityID) FROM Employee WHERE MaritalStatus = 'M' AND STRFTIME('%Y', BirthDate) < '1960' AND Gender = 'M'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(BusinessEntityID) FROM Employee WHERE MaritalStatus = 'M' AND STRFTIME('%Y', BirthDate) < '1960' AND Gender = 'M'", "index": 3401, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['M', 'S']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['M', 'J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n CustomerID integer, -- example: [29825, 29672]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['M', 'A', 'B']\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmarried refers to MaritalStatus = 'M'; male refers to Gender = 'M'; BirthDate < = '1959-12-31';\nHow many married male employees were born before the year 1960?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Accountant', 'Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ReorderPoint integer, -- example: [750, 600]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Style text, -- example: ['U', 'W']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipRate real, -- example: [0.99, 1.99]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nAccountant is a job title; first hired = MIN(HireDate)\nWhen did the company hired its first Accountant?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT MIN(HireDate) FROM Employee WHERE JobTitle = 'Accountant'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT MIN(HireDate) FROM Employee WHERE JobTitle = 'Accountant'", "index": 3402, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Accountant', 'Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ReorderPoint integer, -- example: [750, 600]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Style text, -- example: ['U', 'W']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipRate real, -- example: [0.99, 1.99]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nAccountant is a job title; first hired = MIN(HireDate)\nWhen did the company hired its first Accountant?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n Size text, -- example: ['58', 'M']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductModelID integer, -- example: [6, 33]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nJob position and job title are synonyms; job position that was hired the most refers to MAX(COUNT(JobTitle); HireDate BETWEEN '2007-1-1' AND '2007-12-31';\nIn 2007, which job position was hired the most?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT JobTitle FROM Employee WHERE STRFTIME('%Y', HireDate) = '2007' GROUP BY HireDate ORDER BY COUNT(JobTitle) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT JobTitle FROM Employee WHERE STRFTIME('%Y', HireDate) = '2007' GROUP BY HireDate ORDER BY COUNT(JobTitle) DESC LIMIT 1", "index": 3403, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n Size text, -- example: ['58', 'M']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductModelID integer, -- example: [6, 33]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nJob position and job title are synonyms; job position that was hired the most refers to MAX(COUNT(JobTitle); HireDate BETWEEN '2007-1-1' AND '2007-12-31';\nIn 2007, which job position was hired the most?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n EmailPromotion integer, -- example: [0, 1]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Marketing', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Marketing Specialist', 'Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['HI', '01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n Style text, -- example: ['U', 'W']\n ProductSubcategoryID integer, -- example: [14, 31]\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nage as of 12/31/2015 = SUBTRACT(2015, year(BirthDate)); hourly rate refers to Rate;\nWhat is the age of the oldest Marketing Specialist by 12/31/2015 and what is his/her hourly rate?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT 2015 - STRFTIME('%Y', T1.BirthDate), T2.Rate FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Marketing Specialist' ORDER BY 2015 - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT 2015 - STRFTIME('%Y', T1.BirthDate), T2.Rate FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Marketing Specialist' ORDER BY 2015 - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1", "index": 3404, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n EmailPromotion integer, -- example: [0, 1]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Marketing', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Marketing Specialist', 'Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['HI', '01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n Style text, -- example: ['U', 'W']\n ProductSubcategoryID integer, -- example: [14, 31]\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nage as of 12/31/2015 = SUBTRACT(2015, year(BirthDate)); hourly rate refers to Rate;\nWhat is the age of the oldest Marketing Specialist by 12/31/2015 and what is his/her hourly rate?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AG', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['HE', 'HI', 'ID', '01', '02']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['She', 'He', 'Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['he', 'en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Category text, -- example: ['No Discount', 'Reseller']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['he', 'ar', 'en']\n PRIMARY KEY (CultureID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ntotal due before freight = SUBTRACT(TotalDue, Freight); age at the time an employee was hired = SUBTRACT(HireDate, year(BirthDate);\nWho made the purchase order with the greatest total due before freight? Indicate her employee ID and calculate for his/her age when he/she was hired.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.BusinessEntityID, STRFTIME('%Y', T2.HireDate) - STRFTIME('%Y', T2.BirthDate) FROM PurchaseOrderHeader AS T1 INNER JOIN Employee AS T2 ON T1.EmployeeID = T2.BusinessEntityID ORDER BY T1.TotalDue DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.BusinessEntityID, STRFTIME('%Y', T2.HireDate) - STRFTIME('%Y', T2.BirthDate) FROM PurchaseOrderHeader AS T1 INNER JOIN Employee AS T2 ON T1.EmployeeID = T2.BusinessEntityID ORDER BY T1.TotalDue DESC LIMIT 1", "index": 3405, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AG', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['HE', 'HI', 'ID', '01', '02']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['She', 'He', 'Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['he', 'en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Category text, -- example: ['No Discount', 'Reseller']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['he', 'ar', 'en']\n PRIMARY KEY (CultureID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ntotal due before freight = SUBTRACT(TotalDue, Freight); age at the time an employee was hired = SUBTRACT(HireDate, year(BirthDate);\nWho made the purchase order with the greatest total due before freight? Indicate her employee ID and calculate for his/her age when he/she was hired.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationLevel integer, -- example: [1, 2]\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsalary rate per hour refers to Rate; first 5 employees that were hired refers to 5 oldest HireDate;\nWhat is the salary rate per hour that the company paid to the first 5 employees that they hired?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID ORDER BY T2.HireDate ASC LIMIT 0, 5", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID ORDER BY T2.HireDate ASC LIMIT 0, 5", "index": 3406, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationLevel integer, -- example: [1, 2]\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsalary rate per hour refers to Rate; first 5 employees that were hired refers to 5 oldest HireDate;\nWhat is the salary rate per hour that the company paid to the first 5 employees that they hired?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n ShipToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductLine text, -- example: ['R', 'S']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmaximum orders refers to MaxOrderQty; MaxOrderQty BETWEEN '500' AND '750'; profit on net = SUBTRACT(LastReceiptCost, StandardPrice);\nAmong the vendors with maximum orders betweeen 500 to 750, which vendor has the 10th highest profit on net?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaxOrderQty BETWEEN 500 AND 750 ORDER BY T1.LastReceiptCost - T1.StandardPrice DESC LIMIT 9, 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaxOrderQty BETWEEN 500 AND 750 ORDER BY T1.LastReceiptCost - T1.StandardPrice DESC LIMIT 9, 1", "index": 3407, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n ShipToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductLine text, -- example: ['R', 'S']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmaximum orders refers to MaxOrderQty; MaxOrderQty BETWEEN '500' AND '750'; profit on net = SUBTRACT(LastReceiptCost, StandardPrice);\nAmong the vendors with maximum orders betweeen 500 to 750, which vendor has the 10th highest profit on net?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n Style text, -- example: ['U', 'W']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n BillToAddressID integer, -- example: [985, 921]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\njob position and job title are synonyms; full name = FirstName+MiddleName+LastName;\nWhat was the first job position that the company needed, and who was hired? Indicate his/her full name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.JobTitle, T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.HireDate LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.JobTitle, T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.HireDate LIMIT 1", "index": 3408, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n Style text, -- example: ['U', 'W']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n BillToAddressID integer, -- example: [985, 921]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\njob position and job title are synonyms; full name = FirstName+MiddleName+LastName;\nWhat was the first job position that the company needed, and who was hired? Indicate his/her full name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['W', 'P', 'S']\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n DaysToManufacture integer, -- example: [0, 1]\n Class text, -- example: ['L', 'M']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n CreditRating integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n VacationHours integer, -- example: [99, 1]\n CurrentFlag integer, -- example: [1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwork order refers to TransactionType = 'W'; Quantity BETWEEN 100 AND 250; ReorderPoint< = 375;\nHow many work orders with quantities ranging from 100 to 250 have a reorder point of no more than 375?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.TransactionID) FROM TransactionHistory AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Quantity BETWEEN 100 AND 250 AND T2.ReorderPoint <= 375", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(T1.TransactionID) FROM TransactionHistory AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Quantity BETWEEN 100 AND 250 AND T2.ReorderPoint <= 375", "index": 3409, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['W', 'P', 'S']\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n DaysToManufacture integer, -- example: [0, 1]\n Class text, -- example: ['L', 'M']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n CreditRating integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n VacationHours integer, -- example: [99, 1]\n CurrentFlag integer, -- example: [1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwork order refers to TransactionType = 'W'; Quantity BETWEEN 100 AND 250; ReorderPoint< = 375;\nHow many work orders with quantities ranging from 100 to 250 have a reorder point of no more than 375?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Color text, -- example: ['Black', 'Silver']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Class text, -- example: ['M', 'L']\n Style text, -- example: ['M', 'U', 'W']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TransactionType text, -- example: ['P', 'S']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n EmailPromotion integer, -- example: [0, 1]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n TerritoryID integer, -- example: [5, 6]\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['M', 'S']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfemale refers to Gender = 'F'; male refers to Gender = 'M'; difference in the average salary of female against male employees = SUBTRACT(AVG(Rate where Gender = 'F')), (AVG(Rate where Gender = 'M')));\nHow much is the average salary of female employees in comparison to male employees?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'F'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'F'", "index": 3410, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Color text, -- example: ['Black', 'Silver']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Class text, -- example: ['M', 'L']\n Style text, -- example: ['M', 'U', 'W']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TransactionType text, -- example: ['P', 'S']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n EmailPromotion integer, -- example: [0, 1]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n TerritoryID integer, -- example: [5, 6]\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['M', 'S']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nfemale refers to Gender = 'F'; male refers to Gender = 'M'; difference in the average salary of female against male employees = SUBTRACT(AVG(Rate where Gender = 'F')), (AVG(Rate where Gender = 'M')));\nHow much is the average salary of female employees in comparison to male employees?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductLine text, -- example: ['R', 'S']\n DiscontinuedDate datetime,\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Scheduling Assistant', 'Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPayFrequency = 1 refers to ‘Salary received monthly’; PayFrequency = 2 refers to ‘Salary received biweekly';\nHow frequently does the first-ever Scheduling Assistant get paid?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.PayFrequency FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Scheduling Assistant' ORDER BY T1.HireDate LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.PayFrequency FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Scheduling Assistant' ORDER BY T1.HireDate LIMIT 1", "index": 3411, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductLine text, -- example: ['R', 'S']\n DiscontinuedDate datetime,\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Scheduling Assistant', 'Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPayFrequency = 1 refers to ‘Salary received monthly’; PayFrequency = 2 refers to ‘Salary received biweekly';\nHow frequently does the first-ever Scheduling Assistant get paid?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n ProductModelID integer, -- example: [6, 33]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Max', 'Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncommision percent received per sale refers to CommissionPct; highest commision percent received per sale refers to MAX(CommissionPcT); full name = FirstName+MiddleName+LastName;\nWhat is the full name of the sales person who has the the highest commission percent received per sale?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.CommissionPct DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.CommissionPct DESC LIMIT 1", "index": 3412, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n ProductModelID integer, -- example: [6, 33]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Max', 'Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncommision percent received per sale refers to CommissionPct; highest commision percent received per sale refers to MAX(CommissionPcT); full name = FirstName+MiddleName+LastName;\nWhat is the full name of the sales person who has the the highest commission percent received per sale?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['HE', '01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['he', 'en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['he', 'ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['He', 'Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n Style text, -- example: ['U', 'W']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n TerritoryID integer, -- example: [5, 6]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nage at the time of being hired = SUBTRACT(HireDate, BirthDate); full name = FirstName+MiddleName+LastName;\nWhat is the full name of the second oldest person in the company at the time he was hired?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1, 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1, 1", "index": 3413, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['HE', '01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['he', 'en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['he', 'ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['He', 'Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n Style text, -- example: ['U', 'W']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n TerritoryID integer, -- example: [5, 6]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nage at the time of being hired = SUBTRACT(HireDate, BirthDate); full name = FirstName+MiddleName+LastName;\nWhat is the full name of the second oldest person in the company at the time he was hired?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['U', 'W']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n MiddleName text, -- example: ['J', 'Lee']\n Suffix text, -- example: ['III', 'Jr.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofit = MULTIPLY(SUBTRACT(ListPrice, Standardcost)), (Quantity)));\nWhat is the total profit gained by the company from the product that has the highest amount of quantity ordered from online customers? Indicate the name of the product.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT (T2.ListPrice - T2.StandardCost) * SUM(T1.Quantity), T2.Name FROM ShoppingCartItem AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID, T2.Name, T2.ListPrice, T2.StandardCost, T1.Quantity ORDER BY SUM(T1.Quantity) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT (T2.ListPrice - T2.StandardCost) * SUM(T1.Quantity), T2.Name FROM ShoppingCartItem AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID, T2.Name, T2.ListPrice, T2.StandardCost, T1.Quantity ORDER BY SUM(T1.Quantity) DESC LIMIT 1", "index": 3414, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['U', 'W']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n MiddleName text, -- example: ['J', 'Lee']\n Suffix text, -- example: ['III', 'Jr.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofit = MULTIPLY(SUBTRACT(ListPrice, Standardcost)), (Quantity)));\nWhat is the total profit gained by the company from the product that has the highest amount of quantity ordered from online customers? Indicate the name of the product.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['ID', '01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nProfit on net = SUBTRACT(LastReceiptCost, StandardPrice); full location = AddressLine1+AddressLine2+City+PostalCode;\nWhat is the average lead time of product ID 843? Calculate for its profit on net and indicate the full location to which the vendor is located.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.AverageLeadTime, T1.LastReceiptCost - T1.StandardPrice, T4.AddressLine1, T4.AddressLine2 , T4.City, T4.PostalCode FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN BusinessEntityAddress AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID INNER JOIN Address AS T4 ON T3.AddressID = T4.AddressID WHERE T1.ProductID = 843", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.AverageLeadTime, T1.LastReceiptCost - T1.StandardPrice, T4.AddressLine1, T4.AddressLine2 , T4.City, T4.PostalCode FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN BusinessEntityAddress AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID INNER JOIN Address AS T4 ON T3.AddressID = T4.AddressID WHERE T1.ProductID = 843", "index": 3415, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['ID', '01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nProfit on net = SUBTRACT(LastReceiptCost, StandardPrice); full location = AddressLine1+AddressLine2+City+PostalCode;\nWhat is the average lead time of product ID 843? Calculate for its profit on net and indicate the full location to which the vendor is located.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CustomerID integer, -- example: [29825, 29672]\n ShipMethodID integer, -- example: [5, 1]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n MaritalStatus text, -- example: ['S', 'M']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n Class text, -- example: ['L', 'M']\n Style text, -- example: ['U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nshipping cost and Freight are synonyms; highest shipping cost refers to MAX(Freight);\nWhat is the current status of the order with the highest shipping cost?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT Status FROM SalesOrderHeader ORDER BY Freight DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT Status FROM SalesOrderHeader ORDER BY Freight DESC LIMIT 1", "index": 3416, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CustomerID integer, -- example: [29825, 29672]\n ShipMethodID integer, -- example: [5, 1]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n MaritalStatus text, -- example: ['S', 'M']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n Class text, -- example: ['L', 'M']\n Style text, -- example: ['U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nshipping cost and Freight are synonyms; highest shipping cost refers to MAX(Freight);\nWhat is the current status of the order with the highest shipping cost?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nout of stock product refers to OnOrderQty = 0;\nHow many products are out of stock?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(ProductID) FROM ProductVendor WHERE OnOrderQty = 0", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(ProductID) FROM ProductVendor WHERE OnOrderQty = 0", "index": 3417, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nout of stock product refers to OnOrderQty = 0;\nHow many products are out of stock?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n Revision text, -- example: ['0', '4']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhighest rating refers to MAX(Rating)\nWhich reviewer gives the biggest number of the highest rating?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT ReviewerName FROM ProductReview WHERE Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating DESC LIMIT 1 )", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT ReviewerName FROM ProductReview WHERE Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating DESC LIMIT 1 )", "index": 3418, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n Revision text, -- example: ['0', '4']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhighest rating refers to MAX(Rating)\nWhich reviewer gives the biggest number of the highest rating?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FolderFlag integer, -- example: [1, 0]\n Revision text, -- example: ['0', '4']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n CustomerID integer, -- example: [29825, 29672]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost reviews refers to MAX(count(ProductID))\n\n\nWhich product gets the most reviews?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1", "index": 3419, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FolderFlag integer, -- example: [1, 0]\n Revision text, -- example: ['0', '4']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n CustomerID integer, -- example: [29825, 29672]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost reviews refers to MAX(count(ProductID))\n\n\nWhich product gets the most reviews?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationLevel integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n CustomerID integer, -- example: [29825, 29672]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsalable product refers to FinishedGoodsFlag = 1; biggest amount reviews refers to MAX(count(ProductID))\nWhat is the biggest amount of reviews a salable product gets?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.Comments FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.FinishedGoodsFlag = 1 GROUP BY T1.Comments ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.Comments FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.FinishedGoodsFlag = 1 GROUP BY T1.Comments ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1", "index": 3420, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationLevel integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n CustomerID integer, -- example: [29825, 29672]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsalable product refers to FinishedGoodsFlag = 1; biggest amount reviews refers to MAX(count(ProductID))\nWhat is the biggest amount of reviews a salable product gets?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipToAddressID integer, -- example: [985, 921]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n MaritalStatus text, -- example: ['S', 'M']\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsalable product refers to FinishedGoodsFlag = 1; over 10 reviews refers to count(comments)>10\nPlease list the names of the products that get over 10 reviews and a salable.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.NAME FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.FinishedGoodsFlag = 1 GROUP BY T2.NAME ORDER BY COUNT(T1.comments) > 10", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.NAME FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.FinishedGoodsFlag = 1 GROUP BY T2.NAME ORDER BY COUNT(T1.comments) > 10", "index": 3421, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipToAddressID integer, -- example: [985, 921]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n MaritalStatus text, -- example: ['S', 'M']\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsalable product refers to FinishedGoodsFlag = 1; over 10 reviews refers to count(comments)>10\nPlease list the names of the products that get over 10 reviews and a salable.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PreferredVendorStatus integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n Class text, -- example: ['L', 'M', 'H']\n Style text, -- example: ['M', 'U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n FirstName text, -- example: ['Max', 'Ken', 'Terri']\n LastName text, -- example: ['Low', 'Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['L', 'M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost review refers to MAX(count(comments)); high class refers to Class = 'H'; medium class refers to Class = 'M'; low class refers to Class = 'L'\nWhat is the class of the product with the most reviews?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.Class FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T2.Class ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.Class FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T2.Class ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1", "index": 3422, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PreferredVendorStatus integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n Class text, -- example: ['L', 'M', 'H']\n Style text, -- example: ['M', 'U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n FirstName text, -- example: ['Max', 'Ken', 'Terri']\n LastName text, -- example: ['Low', 'Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['L', 'M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost review refers to MAX(count(comments)); high class refers to Class = 'H'; medium class refers to Class = 'M'; low class refers to Class = 'L'\nWhat is the class of the product with the most reviews?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['S.', 'E', 'M', 'S', 'J', 'Lee']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['M', 'S', '58']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductLine text, -- example: ['M', 'S', 'R']\n Class text, -- example: ['M', 'L']\n ProductModelID integer, -- example: [6, 33]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['S', 'W']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhigh class refers to Class = 'H'; men's product refers to Style = 'M'\nPlease list the e-mails of the reviewers who have reviewed high class.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.EmailAddress FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Class = 'H'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.EmailAddress FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Class = 'H'", "index": 3423, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['S.', 'E', 'M', 'S', 'J', 'Lee']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['M', 'S', '58']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductLine text, -- example: ['M', 'S', 'R']\n Class text, -- example: ['M', 'L']\n ProductModelID integer, -- example: [6, 33]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['S', 'W']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhigh class refers to Class = 'H'; men's product refers to Style = 'M'\nPlease list the e-mails of the reviewers who have reviewed high class.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n ProductLine text, -- example: ['R', 'S']\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Price', 'Sánchez', 'Duffy']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nover 3 price changes refers to count(ListPrice)>3\nPlease list the names of the products that have over 3 price changes.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.Name FROM ProductListPriceHistory AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T2.Name ORDER BY COUNT(T1.ListPrice) > 3", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.Name FROM ProductListPriceHistory AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T2.Name ORDER BY COUNT(T1.ListPrice) > 3", "index": 3424, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n ProductLine text, -- example: ['R', 'S']\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Price', 'Sánchez', 'Duffy']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nover 3 price changes refers to count(ListPrice)>3\nPlease list the names of the products that have over 3 price changes.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['S', 'A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n LastName text, -- example: ['Price', 'Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Hex Nut 5', 'Hex Nut 1', 'AWC Logo Cap', 'Adjustable Race']\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['S', '58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n City text, -- example: ['Ottawa', 'Burnaby']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n TerritoryID integer, -- example: [5, 6]\n CreditCardID integer, -- example: [16281, 5618]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nvendor's selling price refers to StandardPrice\nWhat is the highest vendor's selling price for Hex Nut 5?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5' ORDER BY T1.StandardPrice DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5' ORDER BY T1.StandardPrice DESC LIMIT 1", "index": 3425, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['S', 'A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n LastName text, -- example: ['Price', 'Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Hex Nut 5', 'Hex Nut 1', 'AWC Logo Cap', 'Adjustable Race']\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['S', '58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n City text, -- example: ['Ottawa', 'Burnaby']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n TerritoryID integer, -- example: [5, 6]\n CreditCardID integer, -- example: [16281, 5618]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nvendor's selling price refers to StandardPrice\nWhat is the highest vendor's selling price for Hex Nut 5?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Hex Nut 5', 'Hex Nut 1', 'AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['58', 'M']\n Class text, -- example: ['L', 'M']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CAN', 'CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AverageRate real, -- example: [1.0, 1.5491]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Purchasing', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['CAN', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwebsite purchasing link refers to PurchasingWebServiceURL\nPlease list the website purchasing links of the vendors from whom the product Hex Nut 5 can be purchased.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.PurchasingWebServiceURL FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Name = 'Hex Nut 5'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T3.PurchasingWebServiceURL FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Name = 'Hex Nut 5'", "index": 3426, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Hex Nut 5', 'Hex Nut 1', 'AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['58', 'M']\n Class text, -- example: ['L', 'M']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CAN', 'CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AverageRate real, -- example: [1.0, 1.5491]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Purchasing', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['CAN', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nwebsite purchasing link refers to PurchasingWebServiceURL\nPlease list the website purchasing links of the vendors from whom the product Hex Nut 5 can be purchased.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['LL Fork', 'ML Fork', 'HL Fork', 'All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Price', 'Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Hex Nut 5', 'LL Fork', 'Hex Nut 1', 'HL Fork', 'ML Fork', 'AWC Logo Cap']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n Style text, -- example: ['U', 'W']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHex Nut 5 is name of a product\nPlease give all the list prices of the product LL Fork.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.ListPrice FROM Product AS T1 INNER JOIN ProductListPriceHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'LL Fork'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.ListPrice FROM Product AS T1 INNER JOIN ProductListPriceHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'LL Fork'", "index": 3427, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['LL Fork', 'ML Fork', 'HL Fork', 'All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Price', 'Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Hex Nut 5', 'LL Fork', 'Hex Nut 1', 'HL Fork', 'ML Fork', 'AWC Logo Cap']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n Style text, -- example: ['U', 'W']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nHex Nut 5 is name of a product\nPlease give all the list prices of the product LL Fork.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['M', 'R', 'S']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['M', 'J', 'Lee']\n Suffix text, -- example: ['III', 'Jr.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmountain product line refers to ProductLine = 'M'; sold by over 5 vendors refers to count(Name)>5\nAmong the products from the mountain product line, how many of them are sold by over 2 vendors?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(CASE WHEN T1.ProductLine = 'M' THEN 1 ELSE 0 END) FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID GROUP BY T1.ProductID HAVING COUNT(T1.Name) > 2", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT SUM(CASE WHEN T1.ProductLine = 'M' THEN 1 ELSE 0 END) FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID GROUP BY T1.ProductID HAVING COUNT(T1.Name) > 2", "index": 3428, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['M', 'R', 'S']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['M', 'J', 'Lee']\n Suffix text, -- example: ['III', 'Jr.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmountain product line refers to ProductLine = 'M'; sold by over 5 vendors refers to count(Name)>5\nAmong the products from the mountain product line, how many of them are sold by over 2 vendors?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['M', 'R', 'S']\n Class text, -- example: ['M', 'L']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n Title text, -- example: ['Ms.', 'Mr.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmountain product line refers to ProductLine = 'M'\nAmong the products that get over at least 1 review, how many of them are from the mountain product line?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(CASE WHEN T2.ProductLine = 'M' THEN 1 ELSE 0 END) FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID HAVING COUNT(T1.ProductReviewID) > 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT SUM(CASE WHEN T2.ProductLine = 'M' THEN 1 ELSE 0 END) FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID HAVING COUNT(T1.ProductReviewID) > 1", "index": 3429, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['M', 'R', 'S']\n Class text, -- example: ['M', 'L']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n Title text, -- example: ['Ms.', 'Mr.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmountain product line refers to ProductLine = 'M'\nAmong the products that get over at least 1 review, how many of them are from the mountain product line?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Hex Nut 5', 'Hex Nut 1', 'AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n Style text, -- example: ['U', 'W']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage selling price = divide(sum(StandardPrice), count(BusinessEntityID))\nWhat is the average selling price of different vendors of the product Hex Nut 5?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(T1.StandardPrice) / COUNT(T1.BusinessEntityID) FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT SUM(T1.StandardPrice) / COUNT(T1.BusinessEntityID) FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5'", "index": 3430, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Hex Nut 5', 'Hex Nut 1', 'AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n Style text, -- example: ['U', 'W']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage selling price = divide(sum(StandardPrice), count(BusinessEntityID))\nWhat is the average selling price of different vendors of the product Hex Nut 5?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Home', 'Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Home', 'Cell']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['J', 'Lee']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Manufacturer', 'Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n SalariedFlag integer, -- example: [1, 0]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhome manufactured refers to MakeFlag = 1; average rating = divide(sum(Rating), count(ProductReview))\nPlease list the top 3 house-manufactured products with the highest average rating.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MakeFlag = 1 GROUP BY T2.Name ORDER BY SUM(T1.Rating) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MakeFlag = 1 GROUP BY T2.Name ORDER BY SUM(T1.Rating) DESC LIMIT 1", "index": 3431, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Home', 'Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Home', 'Cell']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['J', 'Lee']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Manufacturer', 'Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n SalariedFlag integer, -- example: [1, 0]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhome manufactured refers to MakeFlag = 1; average rating = divide(sum(Rating), count(ProductReview))\nPlease list the top 3 house-manufactured products with the highest average rating.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Anderson', 'Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nperson in the individual retail refers to PersonType = 'IN'\nName all person in the individual retail whose last name is 'Anderson'.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT FirstName, MiddleName, LastName FROM Person WHERE LastName = 'Anderson' AND PersonType = 'IN'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT FirstName, MiddleName, LastName FROM Person WHERE LastName = 'Anderson' AND PersonType = 'IN'", "index": 3432, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Anderson', 'Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nperson in the individual retail refers to PersonType = 'IN'\nName all person in the individual retail whose last name is 'Anderson'.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesPersonID integer, -- example: [279, 282]\n CurrencyRateID integer, -- example: [4, 8]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsalaried employee refers to SalariedFlag = 1; hired in 2007 and later refers to year(HireDate)> = 2007\nName all salaried employee who are hired in 2007 and later.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.HireDate) >= '2007' AND T2.SalariedFlag = 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.HireDate) >= '2007' AND T2.SalariedFlag = 1", "index": 3433, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesPersonID integer, -- example: [279, 282]\n CurrencyRateID integer, -- example: [4, 8]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nsalaried employee refers to SalariedFlag = 1; hired in 2007 and later refers to year(HireDate)> = 2007\nName all salaried employee who are hired in 2007 and later.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n CustomerID integer, -- example: [29825, 29672]\n ShipMethodID integer, -- example: [5, 1]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n MaritalStatus text, -- example: ['M', 'S']\n VacationHours integer, -- example: [99, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileExtension text, -- example: ['.doc']\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmarried employee refers to MaritalStatus = 'M'; less than 20 vacation hours refers to VacationHours<20\nList the name of married employees with less than 20 vacation hours.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.MaritalStatus = 'M' AND T2.VacationHours < 20", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.MaritalStatus = 'M' AND T2.VacationHours < 20", "index": 3434, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n CustomerID integer, -- example: [29825, 29672]\n ShipMethodID integer, -- example: [5, 1]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n MaritalStatus text, -- example: ['M', 'S']\n VacationHours integer, -- example: [99, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileExtension text, -- example: ['.doc']\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmarried employee refers to MaritalStatus = 'M'; less than 20 vacation hours refers to VacationHours<20\nList the name of married employees with less than 20 vacation hours.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Min', 'Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CreditCardID integer, -- example: [16281, 5618]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Night', 'Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FileExtension text, -- example: ['.doc']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nworking on night shift refers to ShiftID = 3; oldest employee refers to min(BirthDate); age = 2022-year(BirthDate)+1\nName the oldest employee who is working on night shift. How old is the employee?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.FirstName, T1.LastName , STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', BirthDate) FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T3.ShiftId = 3 ORDER BY STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', BirthDate) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.FirstName, T1.LastName , STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', BirthDate) FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T3.ShiftId = 3 ORDER BY STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', BirthDate) DESC LIMIT 1", "index": 3435, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Min', 'Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CreditCardID integer, -- example: [16281, 5618]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Night', 'Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FileExtension text, -- example: ['.doc']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nworking on night shift refers to ShiftID = 3; oldest employee refers to min(BirthDate); age = 2022-year(BirthDate)+1\nName the oldest employee who is working on night shift. How old is the employee?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Revision text, -- example: ['0', '4']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Shipping and Receiving', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n SafetyStockLevel integer, -- example: [1000, 800]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Shipping', 'Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhired in 2009 refers to year(HireDate) = 2009\nList all staff in the Shipping and Receiving department who are hired in 2009.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN Department AS T4 ON T3.DepartmentID = T4.DepartmentID WHERE STRFTIME('%Y', T2.HireDate) = '2009' AND T4.Name = 'Shipping and Receiving'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN Department AS T4 ON T3.DepartmentID = T4.DepartmentID WHERE STRFTIME('%Y', T2.HireDate) = '2009' AND T4.Name = 'Shipping and Receiving'", "index": 3436, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Revision text, -- example: ['0', '4']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Shipping and Receiving', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n SafetyStockLevel integer, -- example: [1000, 800]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Shipping', 'Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhired in 2009 refers to year(HireDate) = 2009\nList all staff in the Shipping and Receiving department who are hired in 2009.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['he', 'en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n ProductLine text, -- example: ['R', 'S']\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['he', 'ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Min', 'Ken', 'Terri']\n LastName text, -- example: ['He', 'Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\noldest employee refers to min(BirthDate)\nWhat is the job title of the oldest employee in the company? In which department is he in?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.JobTitle, T4.Name FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN Department AS T4 ON T3.DepartmentID = T4.DepartmentID ORDER BY T2.HireDate LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.JobTitle, T4.Name FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN Department AS T4 ON T3.DepartmentID = T4.DepartmentID ORDER BY T2.HireDate LIMIT 1", "index": 3437, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['he', 'en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n ProductLine text, -- example: ['R', 'S']\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['he', 'ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Min', 'Ken', 'Terri']\n LastName text, -- example: ['He', 'Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\noldest employee refers to min(BirthDate)\nWhat is the job title of the oldest employee in the company? In which department is he in?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n SizeUnitMeasureCode text, -- example: ['CM']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Sales Representative', 'Chief Executive Officer', 'Vice President of Engineering']\n SalariedFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CurrencyRateID integer, -- example: [4, 8]\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage of sales representatives = divide(count(JobTitle = 'Sales Representative'), count(JobTitle))*100%\nAmong the employees in Adventure Works, calculate the percentage of them working as sales representatives.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(CASE WHEN JobTitle = 'Sales Representative' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(BusinessEntityID) FROM Employee", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN JobTitle = 'Sales Representative' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(BusinessEntityID) FROM Employee", "index": 3438, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n SizeUnitMeasureCode text, -- example: ['CM']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Sales Representative', 'Chief Executive Officer', 'Vice President of Engineering']\n SalariedFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CurrencyRateID integer, -- example: [4, 8]\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\npercentage of sales representatives = divide(count(JobTitle = 'Sales Representative'), count(JobTitle))*100%\nAmong the employees in Adventure Works, calculate the percentage of them working as sales representatives.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Marketing Manager', 'Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Marketing Manager', 'Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TransactionType text, -- example: ['P', 'S']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Marketing', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMarketing Manager is a job title\nPlease provide contact details of all Marketing Managers. State their name and phone number.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.FirstName, T1.LastName, T2.PhoneNumber FROM Person AS T1 INNER JOIN PersonPhone AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.JobTitle = 'Marketing Manager'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.FirstName, T1.LastName, T2.PhoneNumber FROM Person AS T1 INNER JOIN PersonPhone AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.JobTitle = 'Marketing Manager'", "index": 3439, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Marketing Manager', 'Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Marketing Manager', 'Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TransactionType text, -- example: ['P', 'S']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Marketing', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nMarketing Manager is a job title\nPlease provide contact details of all Marketing Managers. State their name and phone number.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['France', 'Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['France', 'Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n CurrencyRateID integer, -- example: [4, 8]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['France', 'Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Frances', 'Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Sales Representative', 'Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFrance territory refers to SalesTerritory.Name = 'France';\nName all stores and its sales representative in France territory.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.Name, T4.FirstName, T4.LastName FROM SalesTerritory AS T1 INNER JOIN Customer AS T2 ON T1.TerritoryID = T2.TerritoryID INNER JOIN Store AS T3 ON T2.StoreID = T3.BusinessEntityID INNER JOIN Person AS T4 ON T2.PersonID = T4.BusinessEntityID WHERE T1.Name = 'France'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T3.Name, T4.FirstName, T4.LastName FROM SalesTerritory AS T1 INNER JOIN Customer AS T2 ON T1.TerritoryID = T2.TerritoryID INNER JOIN Store AS T3 ON T2.StoreID = T3.BusinessEntityID INNER JOIN Person AS T4 ON T2.PersonID = T4.BusinessEntityID WHERE T1.Name = 'France'", "index": 3440, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['France', 'Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['France', 'Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n CurrencyRateID integer, -- example: [4, 8]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['France', 'Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Frances', 'Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Sales Representative', 'Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFrance territory refers to SalesTerritory.Name = 'France';\nName all stores and its sales representative in France territory.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n MiddleName text, -- example: ['S', 'J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['S', 'R']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nStarted selling in 2013 refers to year(SellStartDate) = 2013;\nName all products that started selling in 2013. State its respective vendor's name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.Name, T3.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE STRFTIME('%Y', T1.SellStartDate) = '2013'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.Name, T3.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE STRFTIME('%Y', T1.SellStartDate) = '2013'", "index": 3441, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n MiddleName text, -- example: ['S', 'J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['S', 'R']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nStarted selling in 2013 refers to year(SellStartDate) = 2013;\nName all products that started selling in 2013. State its respective vendor's name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n BillToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['WB-H098', 'AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nState the vendor for product number WB-H098.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.ProductNumber = 'WB-H098'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T3.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.ProductNumber = 'WB-H098'", "index": 3442, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n BillToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['WB-H098', 'AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nState the vendor for product number WB-H098.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFind the vendor with the least average lead time for Product ID 348.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.ProductID = 348 ORDER BY T1.AverageLeadTime ASC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.ProductID = 348 ORDER BY T1.AverageLeadTime ASC LIMIT 1", "index": 3443, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nFind the vendor with the least average lead time for Product ID 348.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OnlineOrderFlag integer, -- example: [0, 1]\n CustomerID integer, -- example: [29825, 29672]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nborn in or after 1970 refers to year(BirthDate) > = 1970;\nState the employee who are born in or after 1970 and with the least sick leave hour.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.FirstName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T1.BirthDate) > '1970' ORDER BY T1.SickLeaveHours LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.FirstName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T1.BirthDate) > '1970' ORDER BY T1.SickLeaveHours LIMIT 1", "index": 3444, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OnlineOrderFlag integer, -- example: [0, 1]\n CustomerID integer, -- example: [29825, 29672]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nborn in or after 1970 refers to year(BirthDate) > = 1970;\nState the employee who are born in or after 1970 and with the least sick leave hour.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'ID', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Each', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nAverage = Divide(Sum(Substract(year(@today),year(BirthDate))),Count(BusinessEntityID) by each Department ID; youngest employee refers to Min(BirthDate);\nCalculate the average age of employee in each department and state which department has the youngest employees.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.BirthDate) + 1 , T3.Name FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 USING (BusinessEntityID) INNER JOIN Department AS T3 USING (DepartmentID) ORDER BY T1.BirthDate DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.BirthDate) + 1 , T3.Name FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 USING (BusinessEntityID) INNER JOIN Department AS T3 USING (DepartmentID) ORDER BY T1.BirthDate DESC LIMIT 1", "index": 3445, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'ID', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n DaysToManufacture integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Each', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nAverage = Divide(Sum(Substract(year(@today),year(BirthDate))),Count(BusinessEntityID) by each Department ID; youngest employee refers to Min(BirthDate);\nCalculate the average age of employee in each department and state which department has the youngest employees.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Style text, -- example: ['U', 'W']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['ID', '01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease provide the IDs of any three AdventureWorks product subcategories.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT DISTINCT ProductCategoryID FROM ProductSubcategory LIMIT 3", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT DISTINCT ProductCategoryID FROM ProductSubcategory LIMIT 3", "index": 3446, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Style text, -- example: ['U', 'W']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['ID', '01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nPlease provide the IDs of any three AdventureWorks product subcategories.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n VacationHours integer, -- example: [99, 1]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['HI', '01', '02']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n ProductLine text, -- example: ['S', 'R']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['S', 'J', 'Lee']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['S', 'A', 'B']\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n288th sales person refers to BusinessEntityID = 288; predited annual sales refers to SalesQuota; actual sales refers to SalesYTD; difference = Substract(SalesQuota(BusinessEntityID(288))), (SalesYTD(BusinessEntityID(288)));\nWhat are the differences between the 288th salesperson's predicted annual sales and his or her actual sales thus far?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SalesYTD - SalesQuota FROM SalesPerson WHERE BusinessEntityID = 288", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT SalesYTD - SalesQuota FROM SalesPerson WHERE BusinessEntityID = 288", "index": 3447, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n VacationHours integer, -- example: [99, 1]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['HI', '01', '02']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n ProductLine text, -- example: ['S', 'R']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['S', 'J', 'Lee']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['S', 'A', 'B']\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n288th sales person refers to BusinessEntityID = 288; predited annual sales refers to SalesQuota; actual sales refers to SalesYTD; difference = Substract(SalesQuota(BusinessEntityID(288))), (SalesYTD(BusinessEntityID(288)));\nWhat are the differences between the 288th salesperson's predicted annual sales and his or her actual sales thus far?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n CustomerID integer, -- example: [29825, 29672]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n Style text, -- example: ['U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n FirstName text, -- example: ['Min', 'Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlowest total sales in last year refers to Min(SalesLastYear);\nPlease list three businesses with the lowest total sales from last year.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT BusinessEntityID FROM SalesPerson ORDER BY SalesLastYear LIMIT 3", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT BusinessEntityID FROM SalesPerson ORDER BY SalesLastYear LIMIT 3", "index": 3448, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n CustomerID integer, -- example: [29825, 29672]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n Style text, -- example: ['U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n FirstName text, -- example: ['Min', 'Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlowest total sales in last year refers to Min(SalesLastYear);\nPlease list three businesses with the lowest total sales from last year.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Each', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Style text, -- example: ['U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Components', 'Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Assembly', 'Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstill need to be assembled means the assembly doesn't finish or still going on which refers to EndDate IS NULL; a depth of 2 refers to BOMLevel = 2;\nHow many materials still need to be assembled and have a depth of 2 between each component and their parent product?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(*) FROM BillOfMaterials WHERE BOMLevel = 2 AND EndDate IS NULL", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(*) FROM BillOfMaterials WHERE BOMLevel = 2 AND EndDate IS NULL", "index": 3449, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Each', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Style text, -- example: ['U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Components', 'Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Assembly', 'Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstill need to be assembled means the assembly doesn't finish or still going on which refers to EndDate IS NULL; a depth of 2 refers to BOMLevel = 2;\nHow many materials still need to be assembled and have a depth of 2 between each component and their parent product?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['U', 'W']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileName text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnot recommended refers to PreferredVendorStatus = 0;\nPlease list any 3 vendors that are not recommended by Adventure Works.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT Name FROM Vendor WHERE PreferredVendorStatus = 0 LIMIT 3", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT Name FROM Vendor WHERE PreferredVendorStatus = 0 LIMIT 3", "index": 3450, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['U', 'W']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileName text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnot recommended refers to PreferredVendorStatus = 0;\nPlease list any 3 vendors that are not recommended by Adventure Works.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n Revision text, -- example: ['0', '4']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Night', 'Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n StandardCost real, -- example: [0.0, 98.77]\n ProductModelID integer, -- example: [6, 33]\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n CustomerID integer, -- example: [29825, 29672]\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbegan work in 2009 or later refers to StartDate> = 2009;\nHow many employees who began working in 2009 or later had night shifts?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Shift AS T2 ON T1.ShiftId = T2.ShiftId WHERE T2.ShiftId = 3 AND STRFTIME('%Y', T2.StartTime) >= '2009'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Shift AS T2 ON T1.ShiftId = T2.ShiftId WHERE T2.ShiftId = 3 AND STRFTIME('%Y', T2.StartTime) >= '2009'", "index": 3451, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n Revision text, -- example: ['0', '4']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Night', 'Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n StandardCost real, -- example: [0.0, 98.77]\n ProductModelID integer, -- example: [6, 33]\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n CustomerID integer, -- example: [29825, 29672]\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbegan work in 2009 or later refers to StartDate> = 2009;\nHow many employees who began working in 2009 or later had night shifts?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n ShipMethodID integer, -- example: [5, 1]\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Bikes', 'Accessories']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbikes is product category\nWhat bike subcategories are there?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.Name FROM ProductSubcategory AS T1 INNER JOIN ProductCategory AS T2 ON T1.ProductCategoryID = T2.ProductCategoryID WHERE T2.name = 'Bikes'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.Name FROM ProductSubcategory AS T1 INNER JOIN ProductCategory AS T2 ON T1.ProductCategoryID = T2.ProductCategoryID WHERE T2.name = 'Bikes'", "index": 3452, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n ShipMethodID integer, -- example: [5, 1]\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Bikes', 'Accessories']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbikes is product category\nWhat bike subcategories are there?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n CurrencyRateID integer, -- example: [4, 8]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MinQty integer, -- Min Quality, example: [0, 11]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhighest yearly sales quota refers to Max(SalesQuota);\nWhich sales areas are expected to have the highest yearly sales quota?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.Name FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID GROUP BY T1.TerritoryID ORDER BY SUM(T1.SalesQuota) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.Name FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID GROUP BY T1.TerritoryID ORDER BY SUM(T1.SalesQuota) DESC LIMIT 1", "index": 3453, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n CurrencyRateID integer, -- example: [4, 8]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MinQty integer, -- Min Quality, example: [0, 11]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhighest yearly sales quota refers to Max(SalesQuota);\nWhich sales areas are expected to have the highest yearly sales quota?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['Customer', 'No Discount', 'Reseller']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n DiscontinuedDate datetime,\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngoods refers to products\nWhat goods were sold to customers in accordance with sales order number 43660?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesOrderID = 43660", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesOrderID = 43660", "index": 3454, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderLineID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n City text, -- example: ['Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['Customer', 'No Discount', 'Reseller']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n DiscontinuedDate datetime,\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngoods refers to products\nWhat goods were sold to customers in accordance with sales order number 43660?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n BillToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n VacationHours integer, -- example: [99, 1]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FileExtension text, -- example: ['.doc']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost order refers to Max(OrderQty);\nPlease list the top 5 products with the most orders.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.Name ORDER BY SUM(T2.OrderQty) DESC LIMIT 0, 5", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.Name ORDER BY SUM(T2.OrderQty) DESC LIMIT 0, 5", "index": 3455, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n BillToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n VacationHours integer, -- example: [99, 1]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FileExtension text, -- example: ['.doc']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmost order refers to Max(OrderQty);\nPlease list the top 5 products with the most orders.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n ShipToAddressID integer, -- example: [985, 921]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Down Tube', 'AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nshelves refer to shelf; down tube is a product\nWhere are the shelves where the down tube product was stored?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.Shelf FROM Product AS T1 INNER JOIN ProductInventory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Down Tube'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.Shelf FROM Product AS T1 INNER JOIN ProductInventory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Down Tube'", "index": 3456, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n ShipToAddressID integer, -- example: [985, 921]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Down Tube', 'AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nshelves refer to shelf; down tube is a product\nWhere are the shelves where the down tube product was stored?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Caps', 'Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Mountain End Caps', 'AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n Color text, -- example: ['Black', 'Silver']\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n Style text, -- example: ['U', 'W']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nOrder Reference Number refers to ReferenceOrderID\nWhat is the order reference number for the \"Mountain End Caps\" product?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.ReferenceOrderID FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Mountain End Caps'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.ReferenceOrderID FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Mountain End Caps'", "index": 3457, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationLevel integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Caps', 'Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['Mountain End Caps', 'AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n Color text, -- example: ['Black', 'Silver']\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n Style text, -- example: ['U', 'W']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostLastYear real, -- example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nOrder Reference Number refers to ReferenceOrderID\nWhat is the order reference number for the \"Mountain End Caps\" product?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OnlineOrderFlag integer, -- example: [0, 1]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['S', 'R']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n12th business refers to BusinessEntityID = 12;\nWhat is the 12th business's first line address?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.AddressLine1 FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T2.BusinessEntityID = 12", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.AddressLine1 FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T2.BusinessEntityID = 12", "index": 3458, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OnlineOrderFlag integer, -- example: [0, 1]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['S', 'R']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\n12th business refers to BusinessEntityID = 12;\nWhat is the 12th business's first line address?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n SalesPersonID integer, -- example: [279, 282]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductLine text, -- example: ['R', 'S']\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n City text, -- example: ['Dallas', 'Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbusiness with ther ID refers to BusinessEntityID\nPlease list any three businesses with their IDs that are located in Dallas City.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.BusinessEntityID FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T1.City = 'Dallas' LIMIT 3", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.BusinessEntityID FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T1.City = 'Dallas' LIMIT 3", "index": 3459, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n SalesPersonID integer, -- example: [279, 282]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductLine text, -- example: ['R', 'S']\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n City text, -- example: ['Dallas', 'Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nbusiness with ther ID refers to BusinessEntityID\nPlease list any three businesses with their IDs that are located in Dallas City.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Thai', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n ComponentID integer, -- example: [749, 750]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Percentage', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n CurrencyRateID integer, -- example: [4, 8]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nArabic and Thai are language names refers to name = 'Arabic'and name = 'Thai'; Differencce in percentage = Subtract(((Count(CultureID(name = 'Arabic'))/Count(CultureID))*100),((Count(CultureID(name = 'Thai'))/Count(CultureID))*100)));\nWhat is the difference in percentage between the product descriptions written in Arabic and Thai?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(CASE WHEN T1.Name = 'Arabic' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.Name = 'Thai' THEN 1 ELSE 0 END) FROM Culture AS T1 INNER JOIN ProductModelProductDescriptionCulture AS T2 ON T1.CultureID = T2.CultureID", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T1.Name = 'Arabic' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.Name = 'Thai' THEN 1 ELSE 0 END) FROM Culture AS T1 INNER JOIN ProductModelProductDescriptionCulture AS T2 ON T1.CultureID = T2.CultureID", "index": 3460, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Thai', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n ComponentID integer, -- example: [749, 750]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Percentage', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n DiscountPct real, -- Discount precentage, example: [0.0]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n CurrencyRateID integer, -- example: [4, 8]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nArabic and Thai are language names refers to name = 'Arabic'and name = 'Thai'; Differencce in percentage = Subtract(((Count(CultureID(name = 'Arabic'))/Count(CultureID))*100),((Count(CultureID(name = 'Thai'))/Count(CultureID))*100)));\nWhat is the difference in percentage between the product descriptions written in Arabic and Thai?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['US', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['U', 'W']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['US', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Percentage', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Northwest', 'Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['US', 'FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nNorthwest refers to Name = 'Northwest'; US refers to CountryRegionCode = 'US'; forecasted annual sales of above 300,000 refers to SalesQuota >300000; Percentage = Divide(Count(TerritoryID(SalesQuota >300000)),Count(TerritoryID))*100\nWhat percentage of businesses in the Northwest US have forecasted annual sales of above 300,000?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(CASE WHEN T1.SalesQuota > 300000 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T2.CountryRegionCode = 'US' AND T2.Name = 'Northwest'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT CAST(SUM(CASE WHEN T1.SalesQuota > 300000 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T2.CountryRegionCode = 'US' AND T2.Name = 'Northwest'", "index": 3461, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['US', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['U', 'W']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['US', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Percentage', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Northwest', 'Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['US', 'FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nNorthwest refers to Name = 'Northwest'; US refers to CountryRegionCode = 'US'; forecasted annual sales of above 300,000 refers to SalesQuota >300000; Percentage = Divide(Count(TerritoryID(SalesQuota >300000)),Count(TerritoryID))*100\nWhat percentage of businesses in the Northwest US have forecasted annual sales of above 300,000?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n Class text, -- example: ['L', 'M']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileExtension text, -- example: ['.doc']\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhighest review score refers to Rating = 5;\nWhat is the name of the product with the almost highest review score?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.Name FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating DESC LIMIT 1 )", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.Name FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating DESC LIMIT 1 )", "index": 3462, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Review', 'Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n Class text, -- example: ['L', 'M']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FileExtension text, -- example: ['.doc']\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhighest review score refers to Rating = 5;\nWhat is the name of the product with the almost highest review score?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Class text, -- example: ['L', 'M']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['Vista', 'SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n TerritoryID integer, -- example: [5, 6]\n CreditCardID integer, -- example: [16281, 5618]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n Revision text, -- example: ['0', '4']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nVista Card refers to CardType = 'Vista'; expire before the year 2007 refers to ExpYear< = 2006;\n\n\nHow many Vista cards expired before the year 2007?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(CreditCardID) FROM CreditCard WHERE CardType = 'Vista' AND ExpYear < 2007", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(CreditCardID) FROM CreditCard WHERE CardType = 'Vista' AND ExpYear < 2007", "index": 3463, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Class text, -- example: ['L', 'M']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['Vista', 'SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n TerritoryID integer, -- example: [5, 6]\n CreditCardID integer, -- example: [16281, 5618]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n Revision text, -- example: ['0', '4']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nVista Card refers to CardType = 'Vista'; expire before the year 2007 refers to ExpYear< = 2006;\n\n\nHow many Vista cards expired before the year 2007?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardID integer, -- example: [16281, 5618]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Night', 'Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nNight shift refers to Name = 'Night';\nWhat time does the company's night shift begin? Indicate the answer in regular form.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT StartTime FROM Shift WHERE Name = 'Night'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT StartTime FROM Shift WHERE Name = 'Night'", "index": 3464, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardID integer, -- example: [16281, 5618]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Night', 'Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nNight shift refers to Name = 'Night';\nWhat time does the company's night shift begin? Indicate the answer in regular form.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n VacationHours integer, -- example: [99, 1]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngreatest difference in sales from previous year to this year refers to Max(Subtract(SalesLastYear,SalesYTD));\nWhich territory has the greatest difference in sales from previous year to this year? Indicate the difference, as well as the name and country of the region.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SalesLastYear - SalesYTD, Name, CountryRegionCode FROM SalesTerritory ORDER BY SalesLastYear - SalesYTD DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT SalesLastYear - SalesYTD, Name, CountryRegionCode FROM SalesTerritory ORDER BY SalesLastYear - SalesYTD DESC LIMIT 1", "index": 3465, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n VacationHours integer, -- example: [99, 1]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ngreatest difference in sales from previous year to this year refers to Max(Subtract(SalesLastYear,SalesYTD));\nWhich territory has the greatest difference in sales from previous year to this year? Indicate the difference, as well as the name and country of the region.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['CM', 'BOX', 'BTL']\n Name text, -- example: ['Centimeter', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['CM', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SickLeaveHours integer, -- example: [69, 20]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CustomerID integer, -- example: [29825, 29672]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nin centimeter refers to SizeUnitMeasureCode = 'CM';\nWhat are the names of the top 6 products that has the biggest size in centimeter and what are its reorder point?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT Name, ReorderPoint FROM Product WHERE SizeUnitMeasureCode = 'CM' ORDER BY Size DESC LIMIT 6", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT Name, ReorderPoint FROM Product WHERE SizeUnitMeasureCode = 'CM' ORDER BY Size DESC LIMIT 6", "index": 3466, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['CM', 'BOX', 'BTL']\n Name text, -- example: ['Centimeter', 'Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['CM', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SickLeaveHours integer, -- example: [69, 20]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n ChangeNumber integer, -- example: [0, 28]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CustomerID integer, -- example: [29825, 29672]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n `Comment` text,\n PRIMARY KEY (SalesOrderID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nin centimeter refers to SizeUnitMeasureCode = 'CM';\nWhat are the names of the top 6 products that has the biggest size in centimeter and what are its reorder point?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\namount to be paid refers to TotalDue;\nHow much is the amount to be paid by the company for the purchase order with the third highest freight amount?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT TotalDue FROM PurchaseOrderHeader ORDER BY Freight DESC LIMIT 2, 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT TotalDue FROM PurchaseOrderHeader ORDER BY Freight DESC LIMIT 2, 1", "index": 3467, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileName text, -- example: ['Documents', 'Overview']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationLevel integer, -- example: [1, 2]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\namount to be paid refers to TotalDue;\nHow much is the amount to be paid by the company for the purchase order with the third highest freight amount?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLightest product refers to Min(Weight); profit if they sell 10 items refers to Subtract (ListPrice , StandardCost) *10;\nWhat profit will the company gain if they sell 10 items of the product that has the lightest weight?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT 10 * (ListPrice - StandardCost) FROM Product WHERE Weight IS NOT NULL ORDER BY Weight LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT 10 * (ListPrice - StandardCost) FROM Product WHERE Weight IS NOT NULL ORDER BY Weight LIMIT 1", "index": 3468, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLightest product refers to Min(Weight); profit if they sell 10 items refers to Subtract (ListPrice , StandardCost) *10;\nWhat profit will the company gain if they sell 10 items of the product that has the lightest weight?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n CurrencyRateID integer, -- example: [4, 8]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Max', 'Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ntax amount refers to TaxAmt; biggest tax amount refers to MAX(TaxAmt);\nHow much is the tax amount of the purchase order with the biggest tax amount? Indicate the purchase order ID.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT TaxAmt, PurchaseOrderID FROM PurchaseOrderHeader ORDER BY TaxAmt DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT TaxAmt, PurchaseOrderID FROM PurchaseOrderHeader ORDER BY TaxAmt DESC LIMIT 1", "index": 3469, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Category text, -- example: ['No Discount', 'Reseller']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n CurrencyRateID integer, -- example: [4, 8]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['ID', 'AD', 'AE']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['ID', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n SizeUnitMeasureCode text, -- example: ['CM']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductSubcategoryID integer, -- example: [14, 31]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Max', 'Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ntax amount refers to TaxAmt; biggest tax amount refers to MAX(TaxAmt);\nHow much is the tax amount of the purchase order with the biggest tax amount? Indicate the purchase order ID.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n SizeUnitMeasureCode text, -- example: ['CM']\n Weight real, -- example: [435.0, 450.0]\n Class text, -- example: ['L', 'M']\n Style text, -- example: ['U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['J', 'Lee']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n CreditRating integer, -- example: [1, 2]\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\noldest employee born before 1969 refers to year(BirthDate)<'1969';\nAmong the employees who were born before 1969, what is the work shift of the 6th oldest employee?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.StartTime, T3.EndTime FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Shift AS T3 ON T2.ShiftId = T3.ShiftId WHERE STRFTIME('%Y', T1.BirthDate) < '1969' ORDER BY T1.BirthDate LIMIT 5, 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T3.StartTime, T3.EndTime FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Shift AS T3 ON T2.ShiftId = T3.ShiftId WHERE STRFTIME('%Y', T1.BirthDate) < '1969' ORDER BY T1.BirthDate LIMIT 5, 1", "index": 3470, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n ReorderPoint integer, -- example: [750, 600]\n SizeUnitMeasureCode text, -- example: ['CM']\n Weight real, -- example: [435.0, 450.0]\n Class text, -- example: ['L', 'M']\n Style text, -- example: ['U', 'W']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n Status integer, -- example: [5]\n OnlineOrderFlag integer, -- example: [0, 1]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['J', 'Lee']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n CreditRating integer, -- example: [1, 2]\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\noldest employee born before 1969 refers to year(BirthDate)<'1969';\nAmong the employees who were born before 1969, what is the work shift of the 6th oldest employee?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Manufacturer', 'Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n Gender text, -- example: ['M', 'F']\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofit on a single item = SUBTRACT(ListPrice, StandardCost); length of time to manufacture refers to DaysToManufacture; fastest to manucature refers to MIN(DaysToManufacture);\nWhich product allows the company to make the highest profit on a single item among those that are the fastest to manufacture? Indicate the rating of the product if there any.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.Name, T2.Rating FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.DaysToManufacture = ( SELECT DaysToManufacture FROM Product ORDER BY DaysToManufacture LIMIT 1 ) ORDER BY T1.ListPrice - T1.StandardCost DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.Name, T2.Rating FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.DaysToManufacture = ( SELECT DaysToManufacture FROM Product ORDER BY DaysToManufacture LIMIT 1 ) ORDER BY T1.ListPrice - T1.StandardCost DESC LIMIT 1", "index": 3471, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Manufacturer', 'Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n Gender text, -- example: ['M', 'F']\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nprofit on a single item = SUBTRACT(ListPrice, StandardCost); length of time to manufacture refers to DaysToManufacture; fastest to manucature refers to MIN(DaysToManufacture);\nWhich product allows the company to make the highest profit on a single item among those that are the fastest to manufacture? Indicate the rating of the product if there any.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Class text, -- example: ['H', 'L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n CustomerID integer, -- example: [29825, 29672]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Bikes', 'Accessories']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['CAN', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Road Bikes', 'Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CAN', 'CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhigh class refers to Class = 'H\"; road bikes is a name of product subcategory; profit = (MULTIPLY(SUBTRACT(ListPrice, StandardCost)), (2)));\nHow much profit can the company gained from selling two high class black Road Bikes with a size of 58?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT 2 * (T1.ListPrice - T1.StandardCost) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID WHERE T1.Class = 'H' AND T1.Color = 'Black' AND T1.Size = 58 AND T2.Name = 'Road Bikes'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT 2 * (T1.ListPrice - T1.StandardCost) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID WHERE T1.Class = 'H' AND T1.Color = 'Black' AND T1.Size = 58 AND T2.Name = 'Road Bikes'", "index": 3472, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Color text, -- example: ['Black', 'Silver']\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n Class text, -- example: ['H', 'L', 'M']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n CustomerID integer, -- example: [29825, 29672]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Bikes', 'Accessories']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['CAN', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Road Bikes', 'Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CAN', 'CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhigh class refers to Class = 'H\"; road bikes is a name of product subcategory; profit = (MULTIPLY(SUBTRACT(ListPrice, StandardCost)), (2)));\nHow much profit can the company gained from selling two high class black Road Bikes with a size of 58?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['M', 'J', 'Lee']\n LastName text, -- example: ['Male', 'Sánchez', 'Duffy']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['M', 'S']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['M', 'A', 'B']\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n BillToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['M', '58']\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['M', 'U', 'W']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Production', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyoungest refers to latest BirthDate; married refers to MaritalStatus = 'M'; production technician is a JobTitle; full name = FirstName+MiddleName+LastName;\nWhat are the full names of the 10 youngest married male production technicians?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle LIKE 'Production Technician%' AND T1.Gender = 'M' AND T1.MaritalStatus = 'M' ORDER BY T1.BirthDate DESC LIMIT 10", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle LIKE 'Production Technician%' AND T1.Gender = 'M' AND T1.MaritalStatus = 'M' ORDER BY T1.BirthDate DESC LIMIT 10", "index": 3473, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['M', 'J', 'Lee']\n LastName text, -- example: ['Male', 'Sánchez', 'Duffy']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['M', 'BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['M', 'S']\n Gender text, -- example: ['M', 'F']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['M', 'A', 'B']\n Quantity integer, -- example: [408, 324]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n BillToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['M', '58']\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['M', 'U', 'W']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ReceivedQty real, -- example: [3.0, 550.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Production', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyoungest refers to latest BirthDate; married refers to MaritalStatus = 'M'; production technician is a JobTitle; full name = FirstName+MiddleName+LastName;\nWhat are the full names of the 10 youngest married male production technicians?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n Status integer, -- example: [5]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductModelID integer, -- example: [6, 33]\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmaximum orders refers to MaxOrderQty; MaxOrderQty = 200; profit on net = SUBTRACT(LastReceiptCost, StandardPrice);\nWhat is the profit on net of the products that have exactly 200 maximum order quantity? Indicate the name of the vendors to which these products were purchased from.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.LastReceiptCost - T1.StandardPrice, T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaxOrderQty = 200", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.LastReceiptCost - T1.StandardPrice, T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaxOrderQty = 200", "index": 3474, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n VacationHours integer, -- example: [99, 1]\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n Status integer, -- example: [5]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ProductModelID integer, -- example: [6, 33]\n DiscontinuedDate datetime,\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nmaximum orders refers to MaxOrderQty; MaxOrderQty = 200; profit on net = SUBTRACT(LastReceiptCost, StandardPrice);\nWhat is the profit on net of the products that have exactly 200 maximum order quantity? Indicate the name of the vendors to which these products were purchased from.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductSubcategoryID integer, -- example: [14, 31]\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnon-sales employee refers to PersonType = 'EM'; rejected purchase order refers to Status = 3;\nWhat is the full name of the non-sales employee who made the most number of rejected purchase orders?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.FirstName, T2.LastName FROM PurchaseOrderHeader AS T1 INNER JOIN Person AS T2 ON T1.EmployeeID = T2.BusinessEntityID WHERE T2.PersonType = 'EM' AND T1.Status = 3 GROUP BY T2.FirstName, T2.LastName ORDER BY COUNT(T1.PurchaseOrderID) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.FirstName, T2.LastName FROM PurchaseOrderHeader AS T1 INNER JOIN Person AS T2 ON T1.EmployeeID = T2.BusinessEntityID WHERE T2.PersonType = 'EM' AND T1.Status = 3 GROUP BY T2.FirstName, T2.LastName ORDER BY COUNT(T1.PurchaseOrderID) DESC LIMIT 1", "index": 3475, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n SalesPersonID integer, -- example: [279, 282]\n TerritoryID integer, -- example: [5, 6]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Sales', 'Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n Status integer, -- example: [2, 1]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductSubcategoryID integer, -- example: [14, 31]\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nnon-sales employee refers to PersonType = 'EM'; rejected purchase order refers to Status = 3;\nWhat is the full name of the non-sales employee who made the most number of rejected purchase orders?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n Size text, -- example: ['58', 'M']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n ChangeNumber integer, -- example: [0, 28]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nminimum order quantity refers to MinOrderQty;\nWhat are the names of the vendor with the second lowest minimum order quantity?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.MaxOrderQty ASC LIMIT 1, 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.MaxOrderQty ASC LIMIT 1, 1", "index": 3476, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n TerritoryID integer, -- example: [5, 6]\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n Size text, -- example: ['58', 'M']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n ChangeNumber integer, -- example: [0, 28]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nminimum order quantity refers to MinOrderQty;\nWhat are the names of the vendor with the second lowest minimum order quantity?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['She', 'He', 'Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['he', 'ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['he', 'en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nVacationHours<10; age at the time of being hired = SUBTRACT(year(HireDate), year(BirthDate)); full name = FirstName+MiddleName+LastName;\nOf the employees whose vacation hours are no more than 10, what is the age of the oldest employee at the time he/she was hired? Indicate his/her full name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate), T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.VacationHours <= 10 ORDER BY STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate), T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.VacationHours <= 10 ORDER BY STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1", "index": 3477, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['She', 'He', 'Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AG', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['he', 'ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['he', 'en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nVacationHours<10; age at the time of being hired = SUBTRACT(year(HireDate), year(BirthDate)); full name = FirstName+MiddleName+LastName;\nOf the employees whose vacation hours are no more than 10, what is the age of the oldest employee at the time he/she was hired? Indicate his/her full name.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['U', 'W']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n City text, -- example: ['Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['Excess Inventory', 'No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndiscount refers to DiscountPct; Excess Inventory is a type of special offer;\nHow many discount are of the type \"Excess Inventory\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(SpecialOfferID) FROM SpecialOffer WHERE Type = 'Excess Inventory'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(SpecialOfferID) FROM SpecialOffer WHERE Type = 'Excess Inventory'", "index": 3478, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n Style text, -- example: ['U', 'W']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n City text, -- example: ['Ottawa', 'Burnaby']\n StateProvinceID integer, -- example: [57, 7]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['Excess Inventory', 'No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n OnlineOrderFlag integer, -- example: [0, 1]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ndiscount refers to DiscountPct; Excess Inventory is a type of special offer;\nHow many discount are of the type \"Excess Inventory\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Manufacturer', 'Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n Suffix text, -- example: ['III', 'Jr.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nproduct is mnanufactured in-house refers to MakeFlag = 1; salable product refers to FinishedGoodsFlag = 1;\nAmong all the products that are manufactured in-house, how many of them are salable?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT SUM(FinishedGoodsFlag) FROM Product WHERE MakeFlag = 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT SUM(FinishedGoodsFlag) FROM Product WHERE MakeFlag = 1", "index": 3479, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n TerritoryID integer, -- example: [5, 6]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileName text, -- example: ['Documents', 'Overview']\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Manufacturer', 'Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n ActiveFlag integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n Availability real, -- example: [0.0, 96.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n LineTotal real, -- example: [201.0, 135.0]\n ReceivedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2014-02-08 10:32:17.0']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n Bonus real, -- example: [0.0, 4100.0]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n Suffix text, -- example: ['III', 'Jr.']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nproduct is mnanufactured in-house refers to MakeFlag = 1; salable product refers to FinishedGoodsFlag = 1;\nAmong all the products that are manufactured in-house, how many of them are salable?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich product has the highest standard cost?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT Name FROM Product ORDER BY StandardCost DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT Name FROM Product ORDER BY StandardCost DESC LIMIT 1", "index": 3480, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n Color text, -- example: ['Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n ActualCost real, -- example: [0.0, 6.0]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n TerritoryID integer, -- example: [5, 6]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n ChangeNumber integer, -- example: [0, 28]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nWhich product has the highest standard cost?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['SC', 'EM', 'SP']\n Title text, -- example: ['Mr.', 'Ms.']\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n SafetyStockLevel integer, -- example: [1000, 800]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FolderFlag integer, -- example: [1, 0]\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['MR', 'SC', 'AD', 'AE']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstore contact refers to PersonType = 'SC';\nAmong the employees who are store contacts, how many of them have a title of \"Mr.\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(BusinessEntityID) FROM Person WHERE PersonType = 'SC' AND Title = 'Mr.'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(BusinessEntityID) FROM Person WHERE PersonType = 'SC' AND Title = 'Mr.'", "index": 3481, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['SC', 'EM', 'SP']\n Title text, -- example: ['Mr.', 'Ms.']\n MiddleName text, -- example: ['J', 'Lee']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n SafetyStockLevel integer, -- example: [1000, 800]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n ProductLine text, -- example: ['R', 'S']\n Class text, -- example: ['L', 'M']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FolderFlag integer, -- example: [1, 0]\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n ShipBase real, -- example: [3.95, 9.95]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n `Comment` text,\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['MR', 'SC', 'AD', 'AE']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstore contact refers to PersonType = 'SC';\nAmong the employees who are store contacts, how many of them have a title of \"Mr.\"?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['SC', 'AD', 'AE']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['SC', 'EM', 'SP']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileExtension text, -- example: ['.doc']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['SC', '01', '02']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['R', 'S']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n Freight real, -- example: [616.0984, 38.8276]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstore contact refers to PersonType = 'SC';\nPlease list the phone numbers of all the store contacts.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.PhoneNumber FROM Person AS T1 INNER JOIN PersonPhone AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.PersonType = 'SC'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.PhoneNumber FROM Person AS T1 INNER JOIN PersonPhone AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.PersonType = 'SC'", "index": 3482, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['SC', 'AD', 'AE']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['SC', 'EM', 'SP']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FileExtension text, -- example: ['.doc']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['SC', '01', '02']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n MakeFlag integer, -- example: [0, 1]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['R', 'S']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n MaritalStatus text, -- example: ['S', 'M']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n TerritoryID integer, -- example: [5, 6]\n ShipToAddressID integer, -- example: [985, 921]\n Freight real, -- example: [616.0984, 38.8276]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstore contact refers to PersonType = 'SC';\nPlease list the phone numbers of all the store contacts.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ReorderPoint integer, -- example: [750, 600]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SickLeaveHours integer, -- example: [69, 20]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Bradley', 'David', 'Ken', 'Terri']\n LastName text, -- example: ['Bradley', 'Sánchez', 'Duffy']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhashed password refers to PasswordHash;\nWhat is the hashed password of David Bradley?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.PasswordHash FROM Person AS T1 INNER JOIN Password AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.FirstName = 'David' AND T1.LastName = 'Bradley'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.PasswordHash FROM Person AS T1 INNER JOIN Password AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.FirstName = 'David' AND T1.LastName = 'Bradley'", "index": 3483, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ReorderPoint integer, -- example: [750, 600]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SickLeaveHours integer, -- example: [69, 20]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Bradley', 'David', 'Ken', 'Terri']\n LastName text, -- example: ['Bradley', 'Sánchez', 'Duffy']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n City text, -- example: ['Ottawa', 'Burnaby']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n Status integer, -- example: [5]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nhashed password refers to PasswordHash;\nWhat is the hashed password of David Bradley?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['E', 'J', 'Lee']\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nemployees who wish to receive e-mail promotions from AdventureWorks and selected partners refers to EmailPromotion = 2;\nPlease list the e-mail addresses of all the employees who wish to receive e-mail promotions from Adventureworks and selected partners.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T2.EmailAddress FROM Person AS T1 INNER JOIN EmailAddress AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.EmailPromotion = 2", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T2.EmailAddress FROM Person AS T1 INNER JOIN EmailAddress AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.EmailPromotion = 2", "index": 3484, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n CostYTD real, -- Cost Year to Date, example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['E', 'J', 'Lee']\n EmailPromotion integer, -- example: [0, 1]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbnailPhotoFileName text, -- example: ['racer02_black_f_small.gif', 'racer02_black_small.gif']\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n ListPrice real, -- example: [0.0, 133.34]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n ActiveFlag integer, -- example: [1, 0]\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Status integer, -- example: [2, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n MaritalStatus text, -- example: ['S', 'M']\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n CommissionPct real, -- Commission percentage, example: [0.0, 0.012]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nemployees who wish to receive e-mail promotions from AdventureWorks and selected partners refers to EmailPromotion = 2;\nPlease list the e-mail addresses of all the employees who wish to receive e-mail promotions from Adventureworks and selected partners.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Bradley', 'David', 'Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Bradley', 'Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredit card number refers to CardNumber;\nPlease show the credit card number of David Bradley.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.CardNumber FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN CreditCard AS T3 ON T2.CreditCardID = T3.CreditCardID WHERE T1.FirstName = 'David' AND T1.LastName = 'Bradley'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T3.CardNumber FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN CreditCard AS T3 ON T2.CreditCardID = T3.CreditCardID WHERE T1.FirstName = 'David' AND T1.LastName = 'Bradley'", "index": 3485, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Bradley', 'David', 'Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Bradley', 'Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n SickLeaveHours integer, -- example: [69, 20]\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n MinQty integer, -- Min Quality, example: [0, 11]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredit card number refers to CardNumber;\nPlease show the credit card number of David Bradley.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionType text, -- example: ['S', 'P']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Bradley', 'David', 'Ken', 'Terri']\n LastName text, -- example: ['Bradley', 'Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n TransactionType text, -- example: ['S', 'W']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n TerritoryID integer, -- example: [5, 6]\n CreditCardID integer, -- example: [16281, 5618]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n StandardCost real, -- example: [0.0, 98.77]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['S', 'A', 'B']\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyear of credit card expiration refers to ExpYear;\nIn which year will the David Bradley's credit card expire?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.ExpYear FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN CreditCard AS T3 ON T2.CreditCardID = T3.CreditCardID WHERE T1.FirstName = 'David' AND T1.LastName = 'Bradley'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T3.ExpYear FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN CreditCard AS T3 ON T2.CreditCardID = T3.CreditCardID WHERE T1.FirstName = 'David' AND T1.LastName = 'Bradley'", "index": 3486, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionType text, -- example: ['S', 'P']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Bradley', 'David', 'Ken', 'Terri']\n LastName text, -- example: ['Bradley', 'Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n TransactionType text, -- example: ['S', 'W']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n TerritoryID integer, -- example: [5, 6]\n CreditCardID integer, -- example: [16281, 5618]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n SubTotal real, -- example: [20565.6206, 1294.2529]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n StandardCost real, -- example: [0.0, 98.77]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n SubTotal real, -- example: [201.04, 272.1015]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n CurrentFlag integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n ChangeNumber integer, -- example: [0, 28]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['S', 'A', 'B']\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyear of credit card expiration refers to ExpYear;\nIn which year will the David Bradley's credit card expire?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['SC', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n DaysToManufacture integer, -- example: [0, 1]\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['SC', 'EM', 'SP']\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyear of credit card expiration refers to ExpYear; ExpYear = 2007; store contact refers to PersonType = 'SC';\nPlease list the names of all the store contact employees whose credit cards expired in 2007.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN CreditCard AS T3 ON T2.CreditCardID = T3.CreditCardID WHERE T3.ExpYear = 2007 AND T1.PersonType = 'SC'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN CreditCard AS T3 ON T2.CreditCardID = T3.CreditCardID WHERE T3.ExpYear = 2007 AND T1.PersonType = 'SC'", "index": 3487, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n ReferenceOrderLineID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['SC', 'AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n SafetyStockLevel integer, -- example: [1000, 800]\n DaysToManufacture integer, -- example: [0, 1]\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n RejectedQty real, -- example: [0.0, 1.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['SC', 'EM', 'SP']\n FirstName text, -- example: ['Ken', 'Terri']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nyear of credit card expiration refers to ExpYear; ExpYear = 2007; store contact refers to PersonType = 'SC';\nPlease list the names of all the store contact employees whose credit cards expired in 2007.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Document Control']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n Style text, -- example: ['U', 'W']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlength of stay in a department = SUBTRACT(EndDate, StartDate);\nWhich employee has been in the Engineering Department the longest? Please give his or her firstname and lastname.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T3.Name = 'Engineering' ORDER BY T2.EndDate - T2.StartDate DESC LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T3.Name = 'Engineering' ORDER BY T2.EndDate - T2.StartDate DESC LIMIT 1", "index": 3488, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Document Control']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n Quantity integer, -- example: [4, 3]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n Color text, -- example: ['Black', 'Silver']\n Style text, -- example: ['U', 'W']\n DiscontinuedDate datetime,\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n ModifiedDate datetime, -- example: ['2011-12-23 00:00:00.0', '2011-04-25 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SickLeaveHours integer, -- example: [69, 20]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nlength of stay in a department = SUBTRACT(EndDate, StartDate);\nWhich employee has been in the Engineering Department the longest? Please give his or her firstname and lastname.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['SC', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Manufacturing', 'Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['SC', 'EM', 'SP']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['SC', '01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstore contact refers to PersonType = 'SC'; year(EndDate)>2007 and year(StartDate)<2007;\nAmong the employees in the Manufacturing group in 2007, how many of them are store contacts?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN Person AS T3 ON T1.BusinessEntityID WHERE T3.PersonType = 'SC' AND T2.GroupName = 'Manufacturing' AND STRFTIME('%Y', T1.EndDate) >= '2007' AND STRFTIME('%Y', T1.StartDate) <= '2007'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN Person AS T3 ON T1.BusinessEntityID WHERE T3.PersonType = 'SC' AND T2.GroupName = 'Manufacturing' AND STRFTIME('%Y', T1.EndDate) >= '2007' AND STRFTIME('%Y', T1.StartDate) <= '2007'", "index": 3489, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['SC', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Manufacturing', 'Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ListPrice real, -- example: [0.0, 133.34]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['SC', 'EM', 'SP']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['SC', '01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nstore contact refers to PersonType = 'SC'; year(EndDate)>2007 and year(StartDate)<2007;\nAmong the employees in the Manufacturing group in 2007, how many of them are store contacts?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Ken', 'Terri']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Finance', 'Document Control']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredit card number refers to CardNumber; employees who left the department refers to EndDate NOT null; Engineering Department is a name of department;\nPlease list the credit card numbers of all the employees who have left the Finance Department.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT T3.CardNumber FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN CreditCard AS T3 ON T1.ModifiedDate = T3.ModifiedDate INNER JOIN PersonCreditCard AS T4 ON T3.CreditCardID = T4.CreditCardID WHERE T2.Name = 'Finance' AND T1.EndDate IS NOT NULL", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT T3.CardNumber FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN CreditCard AS T3 ON T1.ModifiedDate = T3.ModifiedDate INNER JOIN PersonCreditCard AS T4 ON T3.CreditCardID = T4.CreditCardID WHERE T2.Name = 'Finance' AND T1.EndDate IS NOT NULL", "index": 3490, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n FirstName text, -- example: ['Ken', 'Terri']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n LineTotal real, -- example: [201.0, 135.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Finance', 'Document Control']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Status integer, -- example: [2, 1]\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncredit card number refers to CardNumber; employees who left the department refers to EndDate NOT null; Engineering Department is a name of department;\nPlease list the credit card numbers of all the employees who have left the Finance Department.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipMethodID integer, -- example: [5, 1]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['DO', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['DO', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Document Control']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nEmployees who don't wish to receive e-mail promotions refers to EmailPromotion = 0;\nAmong all the employees who don't wish to receive promotion e-mails, how many of them belong to or once belonged to the Engineering Department?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T1.DepartmentID = T3.DepartmentID WHERE T3.Name = 'Engineering' AND T2.EmailPromotion = 0", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T1.DepartmentID = T3.DepartmentID WHERE T3.Name = 'Engineering' AND T2.EmailPromotion = 0", "index": 3491, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n ShipMethodID integer, -- example: [5, 1]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['DO', 'AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['DO', 'AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n Size text, -- example: ['58', 'M']\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n DiscontinuedDate datetime,\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Document Control']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n OrderQty integer, -- Order Quantity, example: [4, 3]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileName text, -- example: ['Documents', 'Overview']\n Revision text, -- example: ['0', '4']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PurchasingWebServiceURL text, -- example: ['www.litwareinc.com/', 'www.treyresearch.net/']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n Quantity integer, -- example: [2, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n Gender text, -- example: ['M', 'F']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n MaxOrderQty integer, -- Max Order Quantity, example: [5, 1000]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n StateProvinceID integer, -- example: [57, 7]\n PostalCode text, -- example: ['K4B 1S2', 'V5A 4X1']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n OrderDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nEmployees who don't wish to receive e-mail promotions refers to EmailPromotion = 0;\nAmong all the employees who don't wish to receive promotion e-mails, how many of them belong to or once belonged to the Engineering Department?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['LL Road Frame Sale', 'No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['LL Road Frame', 'ML Road Frame', 'HL Road Frame', 'All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Road Frames', 'Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLL Road Frame Sale is a description of special offer\nPlease list the product names of all the products on the LL Road Frame Sale.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "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'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "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'", "index": 3492, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesYTD real, -- Sales Year to Date, example: [7887186.7882, 2402176.8476]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['LL Road Frame Sale', 'No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n MinQty integer, -- Min Quality, example: [0, 11]\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n DocumentLevel integer, -- example: [0, 1]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['LL Road Frame', 'ML Road Frame', 'HL Road Frame', 'All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n Instructions text, -- example: ['<root xmlns=\"http://schemas.microsoft.co']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n Status integer, -- example: [5]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Road Frames', 'Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n Quantity integer, -- example: [4, 3]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n Freight real, -- example: [5.026, 6.8025]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n MakeFlag integer, -- example: [0, 1]\n SafetyStockLevel integer, -- example: [1000, 800]\n SizeUnitMeasureCode text, -- example: ['CM']\n DaysToManufacture integer, -- example: [0, 1]\n ProductModelID integer, -- example: [6, 33]\n SellEndDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n DueDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Name', 'Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLL Road Frame Sale is a description of special offer\nPlease list the product names of all the products on the LL Road Frame Sale.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['LL Road Frame Sale', 'No Discount', 'Volume Discount 11 to 14']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Clothing', 'Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['LL Road Frame', 'ML Road Frame', 'HL Road Frame', 'All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FolderFlag integer, -- example: [1, 0]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Road Frames', 'Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLL Road Frame Sale is a description of special offer\nHow many products from the Clothing category were on the LL Road Frame Sale?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT COUNT(T2.ProductID) FROM SpecialOffer AS T1 INNER JOIN SpecialOfferProduct AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID INNER JOIN Product AS T3 ON T2.ProductID = T3.ProductID INNER JOIN ProductSubcategory AS T4 ON T3.ProductSubcategoryID = T4.ProductSubcategoryID INNER JOIN ProductCategory AS T5 ON T4.ProductCategoryID = T5.ProductCategoryID WHERE T1.Description = 'LL Road Frame Sale' AND T4.Name = 'Clothing'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT COUNT(T2.ProductID) FROM SpecialOffer AS T1 INNER JOIN SpecialOfferProduct AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID INNER JOIN Product AS T3 ON T2.ProductID = T3.ProductID INNER JOIN ProductSubcategory AS T4 ON T3.ProductSubcategoryID = T4.ProductSubcategoryID INNER JOIN ProductCategory AS T5 ON T4.ProductCategoryID = T5.ProductCategoryID WHERE T1.Description = 'LL Road Frame Sale' AND T4.Name = 'Clothing'", "index": 3493, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n ProductLine text, -- example: ['R', 'S']\n ProductSubcategoryID integer, -- example: [14, 31]\n ProductModelID integer, -- example: [6, 33]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n FromCurrencyCode text, -- example: ['USD']\n EndOfDayRate real, -- example: [1.0002, 1.55]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n UnitPrice real, -- example: [50.0, 45.0]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPriceDiscount real, -- example: [0.0]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n TotalDue real, -- example: [222.1492, 300.6721]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['LL Road Frame Sale', 'No Discount', 'Volume Discount 11 to 14']\n Category text, -- example: ['No Discount', 'Reseller']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MaxQty integer, -- Max Quality, example: [14, 24]\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n rowguid text, -- example: ['05C4FFDB-4F84-4CDF-ABE5-FDF3216EA74E', '06DF529D-EB11-446F-9570-9EE97B8EA1BF']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Clothing', 'Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['LL Road Frame', 'ML Road Frame', 'HL Road Frame', 'All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n Description text, -- example: ['Chromoly steel.', 'Aluminum alloy cups; large diameter spin']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Suffix text, -- example: ['III', 'Jr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FolderFlag integer, -- example: [1, 0]\n DocumentSummary text, -- example: ['It is important that you maintain your b', 'Guidelines and recommendations for lubri']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Road Frames', 'Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n ModifiedDate datetime, -- example: ['2014-08-08 00:00:00.0', '2008-03-31 00:00:00.0']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n BillToAddressID integer, -- example: [985, 921]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardID integer, -- example: [16281, 5618]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n Freight real, -- example: [616.0984, 38.8276]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n SalariedFlag integer, -- example: [1, 0]\n SickLeaveHours integer, -- example: [69, 20]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nLL Road Frame Sale is a description of special offer\nHow many products from the Clothing category were on the LL Road Frame Sale?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Clothing', 'Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TotalDue real, -- example: [23153.2339, 1457.3288]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n DaysToManufacture integer, -- example: [0, 1]\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Manufacturer', 'Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nproduct is manufactured in-house refers to MakeFlag = 1; salable product refers to FinishedGoodsFlag = 1;\nPlease list the products that are under the Clothing category that are manufactured in-house and salable.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CASE WHEN T1.MakeFlag = 1 THEN T1.Name END FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID INNER JOIN ProductCategory AS T3 ON T2.ProductCategoryID = T3.ProductCategoryID WHERE T2.ProductSubcategoryID = 3", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT CASE WHEN T1.MakeFlag = 1 THEN T1.Name END FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID INNER JOIN ProductCategory AS T3 ON T2.ProductCategoryID = T3.ProductCategoryID WHERE T2.ProductSubcategoryID = 3", "index": 3494, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n ModifiedDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Clothing', 'Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n Revision text, -- example: ['0', '4']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n rowguid text, -- example: ['004EA91C-FCD4-4973-87EF-9059C6E20BB5', '00A7E190-D705-4791-AAB5-AD218497DD06']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:07.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ThumbNailPhoto blob, -- example: ['0x47494638396150003100F70000E3E3FCA6ACB3', '0x47494638396150003100F70000E3E3FCEBECF3']\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n Status integer, -- example: [5]\n AccountNumber text, -- example: ['10-4020-000676', '10-4020-000117']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n TotalDue real, -- example: [23153.2339, 1457.3288]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PreferredVendorStatus integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n CostLastYear real, -- example: [0.0]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n FinishedGoodsFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n DaysToManufacture integer, -- example: [0, 1]\n ProductSubcategoryID integer, -- example: [14, 31]\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n ModifiedDate datetime, -- example: ['2014-02-08 10:01:36.0', '2014-02-08 10:03:55.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ReferenceOrderID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n Quantity integer, -- example: [4, 3]\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ModifiedDate datetime, -- example: ['2013-07-29 00:00:00.0', '2013-12-05 00:00:00.0']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n LoginID text, -- example: ['adventure-works\\\\alan0', 'adventure-works\\\\alejandro0']\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n MaritalStatus text, -- example: ['S', 'M']\n Gender text, -- example: ['M', 'F']\n VacationHours integer, -- example: [99, 1]\n rowguid text, -- example: ['00027A8C-C2F8-4A31-ABA8-8A203638B8F1', '01B119A2-2AF3-4775-818E-B421FECB07A7']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n UnitMeasureCode text, -- example: ['EA', 'IN']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderLineID integer, -- example: [0, 1]\n TransactionType text, -- example: ['W', 'S']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Manufacturer', 'Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n rowguid text, -- example: ['00021813-91EF-4A97-9682-0D2AC8C9EA97', '000392B5-933E-4BFF-945B-FF50AABBB7C0']\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n UnitPrice real, -- example: [2025.0, 2040.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nproduct is manufactured in-house refers to MakeFlag = 1; salable product refers to FinishedGoodsFlag = 1;\nPlease list the products that are under the Clothing category that are manufactured in-house and salable.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Document Control']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nemployees who left a department refers to EndDate NOT null; average stay = AVG(SUBTRACT(year(EndDate)), (year(T1.StartDate)));\nFor all the employees that have left the Engineering Department, what is the average time of their stay?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT CAST(SUM(365 * (STRFTIME('%Y', T1.EndDate) - STRFTIME('%Y', T1.StartDate)) + 30 * (STRFTIME('%m', T1.EndDate) - STRFTIME('%m', T1.StartDate)) + STRFTIME('%d', T1.EndDate) - STRFTIME('%d', T1.StartDate)) AS REAL) / COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID WHERE T2.Name = 'Engineering' AND T1.EndDate IS NOT NULL", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT CAST(SUM(365 * (STRFTIME('%Y', T1.EndDate) - STRFTIME('%Y', T1.StartDate)) + 30 * (STRFTIME('%m', T1.EndDate) - STRFTIME('%m', T1.StartDate)) + STRFTIME('%d', T1.EndDate) - STRFTIME('%d', T1.StartDate)) AS REAL) / COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID WHERE T2.Name = 'Engineering' AND T1.EndDate IS NOT NULL", "index": 3495, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Bin integer, -- example: [1, 5]\n Quantity integer, -- example: [408, 324]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n rowguid text, -- example: ['0022434C-E325-47B0-92A0-7302FFA5046F', '00A811E1-D1A5-47B0-8D94-1C6FBAC4C743']\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n rowguid text, -- example: ['24CB3088-4345-47C4-86C5-17B535133D1E', '41BC2FF6-F0FC-475F-8EB9-CEC0805AA0F2']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n TransactionType text, -- example: ['P', 'S']\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Revision text, -- example: ['0', '4']\n Status integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n FinishedGoodsFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n Size text, -- example: ['58', 'M']\n Weight real, -- example: [435.0, 450.0]\n DaysToManufacture integer, -- example: [0, 1]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n ModifiedDate datetime, -- example: ['ModifiedDate', '2008-04-30 00:00:00.0']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Document Control']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n CountryRegionCode text, -- example: ['FR', 'CA']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n RevisionNumber integer, -- example: [4, 5]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n Freight real, -- example: [5.026, 6.8025]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n StateProvinceID integer, -- example: [57, 7]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n SalesLastYear real, -- example: [0.0, 1750406.4785]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhotoFileName text, -- example: ['racer02_black_f_large.gif', 'racer02_black_large.gif']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n EmailPromotion integer, -- example: [0, 1]\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n MinQty integer, -- Min Quality, example: [0, 11]\n ModifiedDate datetime, -- example: ['2011-04-01 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipRate real, -- example: [0.99, 1.99]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nemployees who left a department refers to EndDate NOT null; average stay = AVG(SUBTRACT(year(EndDate)), (year(T1.StartDate)));\nFor all the employees that have left the Engineering Department, what is the average time of their stay?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Document Control']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage pay rate = AVG(Rate); work in 2007 refers to year(StartDate)<2007 AND year(EndDate)>2007;\nWhat is the average pay rate of the employees who worked in the Engineering Departmentin 2007?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT AVG(T3.Rate) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN EmployeePayHistory AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Name = 'Engineering' AND STRFTIME('%Y', EndDate) > '2007' AND STRFTIME('%Y', T1.StartDate) < '2007'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT AVG(T3.Rate) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN EmployeePayHistory AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Name = 'Engineering' AND STRFTIME('%Y', EndDate) > '2007' AND STRFTIME('%Y', T1.StartDate) < '2007'", "index": 3496, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n ModifiedDate datetime, -- example: ['2017-12-13 13:58:03.0', '2013-05-30 00:00:00.0']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n EmailPromotion integer, -- example: [0, 1]\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n Rate real, -- example: [125.5, 63.4615]\n PayFrequency integer, -- example: [2, 1]\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n EndDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n ModifiedDate datetime, -- example: ['2011-06-13 00:00:00.0', '2011-06-19 00:00:00.0']\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardNumber text, -- example: ['11111000471254', '11111002034157']\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxRate real, -- example: [14.0, 14.25]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n NationalIDNumber text, -- example: ['10708100', '109272464']\n OrganizationLevel integer, -- example: [1, 2]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n VacationHours integer, -- example: [99, 1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n CurrencyRateDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Work', 'Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PreferredVendorStatus integer, -- example: [1, 0]\n ActiveFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ProductAssemblyID integer, -- example: [3, 316]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n EndDate datetime, -- example: ['2010-05-03 00:00:00.0', '2010-05-17 00:00:00.0']\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine2 text, -- example: ['Space 55', 'Unit B-105']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n DueDate datetime, -- example: ['2011-04-30 00:00:00.0', '2011-05-14 00:00:00.0']\n ProductID integer, -- example: [1, 359]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n SizeUnitMeasureCode text, -- example: ['CM']\n ProductModelID integer, -- example: [6, 33]\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n Resume text, -- example: ['<ns:Resume xmlns:ns=\"http://schemas.micr']\n ModifiedDate datetime, -- example: ['2007-06-23 00:00:00.0', '2013-12-22 18:32:21.0']\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n Quantity integer, -- example: [2, 1]\n ActualCost real, -- example: [0.0, 6.0]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n EndDate datetime, -- example: ['2012-11-29 00:00:00.0', '2012-09-29 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n Rating integer, -- example: [5, 4]\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n rowguid text, -- example: ['00FFDFAC-0207-4DF0-8051-7D3C884816F3', '016CBBE9-D51B-4A50-94CD-5FF2DA577C5B']\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Engineering', 'Document Control']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n SalesOrderNumber text, -- example: ['SO43659', 'SO43660']\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n `Comment` text,\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n Name text, -- example: ['Ain', 'Aisne']\n TerritoryID integer, -- example: [6, 1]\n ModifiedDate datetime, -- example: ['2014-02-08 10:17:21.0', '2008-04-30 00:00:00.0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n EmailAddress text, -- example: ['ken0@adventure-works.com', 'terri0@adventure-works.com']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n MinOrderQty integer, -- Min Order Quantity, example: [1, 100]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\naverage pay rate = AVG(Rate); work in 2007 refers to year(StartDate)<2007 AND year(EndDate)>2007;\nWhat is the average pay rate of the employees who worked in the Engineering Departmentin 2007?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n ListPrice real, -- example: [0.0, 133.34]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Percentage', 'Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Clothing', 'Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nselling price refers to ListPrice; highest selling price refers to MAX(ListPrice); lowest selling price refers to MIN(ListPrice);\nHow much more expensive in percentage is the product with the highest selling price from the product with the lowest selling price in the Clothing category?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT (MAX(T1.ListPrice) - MIN(T1.ListPrice)) * 100 / MIN(T1.ListPrice) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID INNER JOIN ProductCategory AS T3 ON T2.ProductCategoryID = T3.ProductCategoryID WHERE T3.Name = 'Clothing'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT (MAX(T1.ListPrice) - MIN(T1.ListPrice)) * 100 / MIN(T1.ListPrice) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID INNER JOIN ProductCategory AS T3 ON T2.ProductCategoryID = T3.ProductCategoryID WHERE T3.Name = 'Clothing'", "index": 3497, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesQuota real, -- example: [300000.0, 250000.0]\n Bonus real, -- example: [0.0, 4100.0]\n ModifiedDate datetime, -- example: ['2010-12-28 00:00:00.0', '2011-05-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n AverageRate real, -- example: [1.0, 1.5491]\n EndOfDayRate real, -- example: [1.0002, 1.55]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n CarrierTrackingNumber text, -- example: ['4911-403C-98', '6431-4D57-83']\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n StartTime text, -- example: ['07:00:00', '15:00:00']\n EndTime text, -- example: ['15:00:00', '23:00:00']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n SalesQuota real, -- example: [28000.0, 7000.0]\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n PersonType text, -- example: ['EM', 'SP']\n Suffix text, -- example: ['III', 'Jr.']\n AdditionalContactInfo text, -- example: ['<AdditionalContactInfo xmlns=\"http://sch']\n rowguid text, -- example: ['000191EF-7424-4A5F-AB19-0852B1F0B78D', '00034881-67FA-4CCA-908A-B1D42030979E']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n SpatialLocation text, -- example: ['0x00000000010100000067A89189898A5EC0AE8B', '0x000000000101000000BC262A0A03905EC0D6FA']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ScheduledStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScheduledEndDate datetime, -- example: ['2011-06-14 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n DiscountPct real, -- Discount precentage, example: [0.0]\n Type text, -- example: ['No Discount', 'Volume Discount']\n Category text, -- example: ['No Discount', 'Reseller']\n MaxQty integer, -- Max Quality, example: [14, 24]\n rowguid text, -- example: ['0290C4F5-191F-4337-AB6B-0A2DDE03CBF9', '03E3594D-6EBB-46A6-B8EE-A9289C0C2E47']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n RejectedQty real, -- example: [0.0, 1.0]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n MakeFlag integer, -- example: [0, 1]\n ReorderPoint integer, -- example: [750, 600]\n ListPrice real, -- example: [0.0, 133.34]\n WeightUnitMeasureCode text, -- example: ['G', 'LB']\n ProductSubcategoryID integer, -- example: [14, 31]\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n ModifiedDate datetime,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n ModifiedDate datetime, -- example: ['2012-11-22 00:00:00.0', '2012-11-23 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n OrderQty integer, -- Order Quantity, example: [8, 15]\n StockedQty integer, -- Stocked Quantity, example: [8, 15]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n LastReceiptDate datetime, -- example: ['2011-08-29 00:00:00.0', '2011-08-25 00:00:00.0']\n OnOrderQty integer, -- On Order Quantity, example: [3, 300]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n ModifiedDate datetime, -- example: ['2017-12-13 13:21:02.0', '2017-12-13 13:21:03.0']\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n ListPrice real, -- example: [33.6442, 34.99]\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n TransactionType text, -- example: ['W', 'S']\n Quantity integer, -- example: [2, 1]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Percentage', 'Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Clothing', 'Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n Status integer, -- example: [4, 1]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ShipDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n SalesPersonID integer, -- example: [279, 282]\n ShipToAddressID integer, -- example: [985, 921]\n CurrencyRateID integer, -- example: [4, 8]\n Freight real, -- example: [616.0984, 38.8276]\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n ModifiedDate datetime, -- example: ['2008-03-31 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n CostLastYear real, -- example: [0.0]\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n ComponentID integer, -- example: [749, 750]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n JobTitle text, -- example: ['Chief Executive Officer', 'Vice President of Engineering']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n SalariedFlag integer, -- example: [1, 0]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Owner integer, -- example: [217, 219]\n FolderFlag integer, -- example: [1, 0]\n FileExtension text, -- example: ['.doc']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ReasonType text, -- example: ['Other', 'Promotion']\n PRIMARY KEY (SalesReasonID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nselling price refers to ListPrice; highest selling price refers to MAX(ListPrice); lowest selling price refers to MIN(ListPrice);\nHow much more expensive in percentage is the product with the highest selling price from the product with the lowest selling price in the Clothing category?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n TaxRate real, -- example: [14.0, 14.25]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['58', 'M']\n Style text, -- example: ['U', 'W']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncost refers to StandardCost; cost the least refers to MIN(StandardCost);\nWhich product cost the least in 2013?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT ProductID FROM ProductCostHistory WHERE StartDate LIKE '2013%' ORDER BY StandardCost LIMIT 1", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT ProductID FROM ProductCostHistory WHERE StartDate LIKE '2013%' ORDER BY StandardCost LIMIT 1", "index": 3498, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n OrganizationNode text, -- example: ['/1/', '/1/1/']\n OrganizationLevel integer, -- example: [1, 2]\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n CurrentFlag integer, -- example: [1]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n CountryRegionCode text, -- example: ['US', 'CA']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n ModifiedDate datetime, -- example: ['2011-04-23 00:00:00.0', '2011-05-07 00:00:00.0']\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n rowguid text, -- example: ['10A7C342-CA82-48D4-8A38-46A2EB089B74', '2BE3BE36-D9A2-4EEE-B593-ED895D97C2A6']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n AverageLeadTime integer, -- example: [17, 19]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n StartDate datetime, -- example: ['2010-05-26 00:00:00.0', '2010-03-04 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ShoppingCartID text, -- example: ['14951', '20621']\n Quantity integer, -- example: [3, 4]\n ProductID integer, -- example: [862, 881]\n DateCreated datetime, -- example: ['2013-11-09 17:54:07.0']\n ModifiedDate datetime, -- example: ['2013-11-09 17:54:07.0']\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualStartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-09 00:00:00.0']\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PlannedCost real, -- example: [92.25, 87.5]\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n ModifiedDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n rowguid text, -- example: ['8A1901E4-671B-431A-871C-EADB2942E9EE', 'B5FF9EFD-72A2-4F87-830B-F338FDD4D162']\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n NameStyle integer, -- example: [0]\n MiddleName text, -- example: ['J', 'Lee']\n LastName text, -- example: ['Sánchez', 'Duffy']\n Suffix text, -- example: ['III', 'Jr.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n rowguid text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n SalesPersonID integer, -- example: [279, 276]\n Demographics text, -- example: ['<StoreSurvey xmlns=\"http://schemas.micro']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n rowguid text, -- example: ['00CE9171-8944-4D49-BA37-485C1D122F5C', '02200AA0-C369-4D77-A67C-75973EFDA81B']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n ActualCost real, -- example: [50.0, 45.0]\n PRIMARY KEY (TransactionID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n rowguid text, -- example: ['107E8356-E7A8-463D-B60C-079FFF467F3F', '22F4E461-28CF-4ACE-A980-F686CF112EC8']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n AccountNumber text, -- example: ['ADATUM0001', 'ADVANCED0001']\n CreditRating integer, -- example: [1, 2]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n PasswordHash text, -- example: ['pbFwXWE99vobT6g+vPWFy93NtUU/orrIWafF01hc', 'bawRVNrZQYQ05qF05Gz6VLilnviZmrqBReTTAGAu']\n PasswordSalt text, -- example: ['bE3XiWw=', 'EjJaC3U=']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Description text, -- example: ['No Discount', 'Volume Discount 11 to 14']\n Type text, -- example: ['No Discount', 'Volume Discount']\n StartDate datetime, -- example: ['2011-05-01 00:00:00.0', '2011-05-31 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n ReferenceOrderID integer, -- example: [41590, 41591]\n ReferenceOrderLineID integer, -- example: [0, 1]\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n CostRate real, -- example: [0.0, 22.5]\n Availability real, -- example: [0.0, 96.0]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n SubTotal real, -- example: [201.04, 272.1015]\n TaxAmt real, -- Tax Amount, example: [16.0832, 21.7681]\n TotalDue real, -- example: [222.1492, 300.6721]\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n AddressLine1 text, -- example: [\"#500-75 O'Connor Street\", '#9900 2700 Production Way']\n StateProvinceID integer, -- example: [57, 7]\n rowguid text, -- example: ['00093F9C-0487-4723-B376-D90FF565AD6F', '000A2255-2D8E-4D99-B82F-7013B256EE31']\n ModifiedDate datetime, -- example: ['2007-12-04 00:00:00.0', '2008-11-30 00:00:00.0']\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n RevisionNumber integer, -- example: [8, 9]\n OnlineOrderFlag integer, -- example: [0, 1]\n SalesPersonID integer, -- example: [279, 282]\n BillToAddressID integer, -- example: [985, 921]\n ShipMethodID integer, -- example: [5, 1]\n CreditCardID integer, -- example: [16281, 5618]\n CurrencyRateID integer, -- example: [4, 8]\n SubTotal real, -- example: [20565.6206, 1294.2529]\n TotalDue real, -- example: [23153.2339, 1457.3288]\n rowguid text, -- example: ['0000DE87-AB3F-4920-AC46-C404834241A0', '00032DF7-5D34-4ECC-9BC2-353D3C918E93']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n rowguid text, -- example: ['009F7660-44A6-4ADF-BD4B-A5D1B79993F5', '132E4721-32DD-4A73-B556-1837F3A2B9AE']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Document blob, -- example: ['0xD0CF11E0A1B11AE10000000000000000000000']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n SalesYTD real, -- sales year to date, example: [559697.5639, 3763178.1787]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-07-17 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n EmailAddress text, -- example: ['john@fourthcoffee.com', 'david@graphicdesigninstitute.com']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n ModifiedDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n StateProvinceCode text, -- example: ['01', '02']\n IsOnlyStateProvinceFlag integer, -- example: [0, 1]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0', '2012-10-19 09:56:38.0']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n TaxType integer, -- example: [1, 2]\n TaxRate real, -- example: [14.0, 14.25]\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n SafetyStockLevel integer, -- example: [1000, 800]\n StandardCost real, -- example: [0.0, 98.77]\n Size text, -- example: ['58', 'M']\n Style text, -- example: ['U', 'W']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n CardType text, -- example: ['SuperiorCard', 'Distinguish']\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n ExpYear integer, -- Expiration Year, example: [2006, 2005]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n GroupName text, -- example: ['Research and Development', 'Sales and Marketing']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2017-12-13 13:19:22.0']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n StartDate datetime, -- example: ['2011-06-03 00:00:00.0', '2011-06-04 00:00:00.0']\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n OrderQty integer, -- example: [1, 3]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n rowguid text, -- example: ['0000C99C-2B71-4885-B976-C1CCAE896EF2', '00010EA0-5D0F-4F0A-A3FB-8FE8A8210956']\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n StartTime text, -- example: ['07:00:00', '15:00:00']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n EndDate date, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n StandardCost real, -- example: [12.0278, 13.8782]\n ModifiedDate datetime, -- example: ['2012-05-29 00:00:00.0', '2013-05-29 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\ncost refers to StandardCost; cost the least refers to MIN(StandardCost);\nWhich product cost the least in 2013?\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }
nl2sql
[ { "content": "You are a helpful assistant.", "role": "system" }, { "content": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Yellow', 'Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n Class text, -- example: ['L', 'M']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nList all products with the color yellow.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "role": "user" } ]
nl2sql
{ "ground_truth": "SELECT ProductID FROM Product WHERE Color = 'Yellow'", "style": "rule" }
{ "db_id": "works_cycles.sqlite", "gt_sql": "SELECT ProductID FROM Product WHERE Color = 'Yellow'", "index": 3499, "question": "Task Overview:\nYou are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question.\n\nDatabase Engine:\nSQLite\n\nDatabase Schema:\nCREATE TABLE PhoneNumberType (\n PhoneNumberTypeID integer, -- example: [1, 2]\n Name text, -- Phone Number, example: ['Cell', 'Home']\n PRIMARY KEY (PhoneNumberTypeID)\n);\n\nCREATE TABLE ProductCategory (\n ProductCategoryID integer, -- example: [3, 4]\n Name text, -- example: ['Accessories', 'Bikes']\n PRIMARY KEY (ProductCategoryID)\n);\n\nCREATE TABLE Vendor (\n BusinessEntityID integer, -- example: [1596, 1496]\n Name text, -- example: ['Australia Bike Retailer', 'Allenson Cycles']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_vendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ShoppingCartItem (\n ShoppingCartItemID integer, -- example: [2, 4]\n ProductID integer, -- example: [862, 881]\n PRIMARY KEY (ShoppingCartItemID),\n CONSTRAINT fk_shoppingcartitem_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE PurchaseOrderDetail (\n PurchaseOrderID integer, -- example: [1, 2]\n PurchaseOrderDetailID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n StockedQty real, -- example: [3.0, 550.0]\n PRIMARY KEY (PurchaseOrderDetailID),\n CONSTRAINT fk_purchaseorderdetail_purchaseorderid FOREIGN KEY (PurchaseOrderID) REFERENCES PurchaseOrderHeader (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderdetail_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE Currency (\n CurrencyCode text, -- example: ['ALL', 'AED', 'AFA']\n Name text, -- example: ['Afghani', 'Algerian Dinar']\n PRIMARY KEY (CurrencyCode)\n);\n\nCREATE TABLE ShipMethod (\n ShipMethodID integer, -- example: [4, 3]\n Name text, -- example: ['CARGO TRANSPORT 5', 'OVERNIGHT J-FAST']\n ShipBase real, -- example: [3.95, 9.95]\n PRIMARY KEY (ShipMethodID)\n);\n\nCREATE TABLE WorkOrder (\n WorkOrderID integer, -- example: [1, 2]\n ProductID integer, -- example: [722, 725]\n ScrappedQty integer, -- Scrapped Quantity, example: [0, 1]\n ScrapReasonID integer, -- example: [7, 11]\n PRIMARY KEY (WorkOrderID),\n CONSTRAINT fk_workorder_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_workorder_scrapreasonid FOREIGN KEY (ScrapReasonID) REFERENCES ScrapReason (ScrapReasonID)\n);\n\nCREATE TABLE PersonCreditCard (\n BusinessEntityID integer, -- example: [293, 295]\n CreditCardID integer, -- example: [17038, 15369]\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, CreditCardID),\n CONSTRAINT fk_personcreditcard_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_personcreditcard_creditcardid FOREIGN KEY (CreditCardID) REFERENCES CreditCard (CreditCardID)\n);\n\nCREATE TABLE SalesReason (\n SalesReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Price', 'On Promotion']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesReasonID)\n);\n\nCREATE TABLE ProductPhoto (\n ProductPhotoID integer, -- example: [69, 70]\n LargePhoto blob, -- example: ['0x474946383961F0009500F70000D3D3FEE2E3FE', '0x474946383961F0009500F7000086878AECEDFE']\n PRIMARY KEY (ProductPhotoID)\n);\n\nCREATE TABLE ProductListPriceHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productlistpricehistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE SalesOrderHeaderSalesReason (\n SalesOrderID integer, -- example: [43697, 43702]\n SalesReasonID integer, -- example: [5, 9]\n PRIMARY KEY (SalesOrderID, SalesReasonID),\n CONSTRAINT fk_salesorderheadersalesreason_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderheadersalesreason_salesreasonid FOREIGN KEY (SalesReasonID) REFERENCES SalesReason (SalesReasonID)\n);\n\nCREATE TABLE AddressType (\n AddressTypeID integer, -- example: [4, 2]\n Name text, -- example: ['Archive', 'Billing']\n PRIMARY KEY (AddressTypeID)\n);\n\nCREATE TABLE ProductSubcategory (\n ProductSubcategoryID integer, -- example: [2, 3]\n ProductCategoryID integer, -- example: [1, 2]\n Name text, -- example: ['Bib-Shorts', 'Bike Racks']\n rowguid text, -- example: ['000310C0-BCC8-42C4-B0C3-45AE611AF06B', '02C5061D-ECDC-4274-B5F1-E91D76BC3F37']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ProductSubcategoryID),\n CONSTRAINT fk_productsubcategory_productcategoryid FOREIGN KEY (ProductCategoryID) REFERENCES ProductCategory (ProductCategoryID)\n);\n\nCREATE TABLE SalesOrderHeader (\n SalesOrderID integer, -- example: [71821, 44088]\n OrderDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-06-01 00:00:00.0']\n DueDate datetime, -- example: ['2011-06-12 00:00:00.0', '2011-06-13 00:00:00.0']\n ShipDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PurchaseOrderNumber text, -- example: ['PO522145787', 'PO18850127500']\n CustomerID integer, -- example: [29825, 29672]\n CreditCardApprovalCode text, -- example: ['105041Vi84182', '115213Vi29411']\n CurrencyRateID integer, -- example: [4, 8]\n TaxAmt real, -- Tax Amount, example: [1971.5149, 124.2483]\n Freight real, -- example: [616.0984, 38.8276]\n ModifiedDate datetime, -- example: ['2011-06-07 00:00:00.0', '2011-06-08 00:00:00.0']\n PRIMARY KEY (SalesOrderID)\n);\n\nCREATE TABLE ProductModel (\n ProductModelID integer, -- example: [82, 57]\n Name text, -- example: ['All-Purpose Bike Stand', 'Bike Wash']\n CatalogDescription text, -- example: ['<?xml-stylesheet href=\"ProductDescriptio']\n ModifiedDate datetime, -- example: ['2013-04-30 00:00:00.0', '2011-05-01 00:00:00.0']\n PRIMARY KEY (ProductModelID)\n);\n\nCREATE TABLE Password (\n BusinessEntityID integer, -- example: [1, 2]\n rowguid text, -- example: ['329EACBE-C883-4F48-B8B6-17AA4627EFFF', 'A4C82398-7466-4FE6-B9EE-CEC34D116F68']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_password_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Customer (\n CustomerID integer,\n PersonID integer,\n StoreID integer,\n TerritoryID integer,\n AccountNumber text,\n PRIMARY KEY (CustomerID),\n CONSTRAINT fk_customer_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_customer_storeid FOREIGN KEY (StoreID) REFERENCES Store (BusinessEntityID),\n CONSTRAINT fk_customer_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE ProductDescription (\n ProductDescriptionID integer, -- example: [1954, 1370]\n PRIMARY KEY (ProductDescriptionID)\n);\n\nCREATE TABLE ProductVendor (\n ProductID integer, -- example: [1, 2]\n BusinessEntityID integer, -- example: [1580, 1688]\n StandardPrice real, -- example: [47.87, 39.92]\n LastReceiptCost real, -- example: [50.2635, 41.916]\n UnitMeasureCode text, -- example: ['CS', 'CTN']\n PRIMARY KEY (ProductID, BusinessEntityID),\n CONSTRAINT fk_productvendor_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productvendor_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_productvendor_unitmeasurecode FOREIGN KEY (UnitMeasureCode) REFERENCES UnitMeasure (UnitMeasureCode)\n);\n\nCREATE TABLE ScrapReason (\n ScrapReasonID integer, -- example: [1, 2]\n Name text, -- example: ['Brake assembly not as ordered', 'Color incorrect']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (ScrapReasonID)\n);\n\nCREATE TABLE CreditCard (\n CreditCardID integer, -- example: [11935, 12094]\n ExpMonth integer, -- Expiration Month, example: [11, 8]\n PRIMARY KEY (CreditCardID)\n);\n\nCREATE TABLE BusinessEntityAddress (\n BusinessEntityID integer, -- example: [1, 2]\n AddressID integer, -- example: [249, 293]\n AddressTypeID integer, -- example: [2, 3]\n rowguid text, -- example: ['00013363-E32F-4615-9439-AFF156D480AE', '0001CCDA-AD2B-4BBE-8047-CAC51EFDBB53']\n ModifiedDate datetime, -- example: ['2014-09-12 11:15:06.0', '2011-08-01 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, AddressID, AddressTypeID),\n CONSTRAINT fk_businessentityaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentityaddress_addressid FOREIGN KEY (AddressID) REFERENCES Address (AddressID),\n CONSTRAINT fk_businessentityaddress_addresstypeid FOREIGN KEY (AddressTypeID) REFERENCES AddressType (AddressTypeID)\n);\n\nCREATE TABLE PurchaseOrderHeader (\n PurchaseOrderID integer, -- example: [1, 2]\n EmployeeID integer, -- example: [258, 254]\n VendorID integer, -- example: [1580, 1496]\n ShipMethodID integer, -- example: [3, 5]\n ModifiedDate datetime, -- example: ['2011-04-25 00:00:00.0', '2011-05-09 00:00:00.0']\n PRIMARY KEY (PurchaseOrderID),\n CONSTRAINT fk_purchaseorderheader_employeeid FOREIGN KEY (EmployeeID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_vendorid FOREIGN KEY (VendorID) REFERENCES Vendor (BusinessEntityID),\n CONSTRAINT fk_purchaseorderheader_shipmethodid FOREIGN KEY (ShipMethodID) REFERENCES ShipMethod (ShipMethodID)\n);\n\nCREATE TABLE BillOfMaterials (\n BillOfMaterialsID integer, -- example: [893, 271]\n BOMLevel integer, -- bill of materials level, example: [2, 1]\n PerAssemblyQty real, -- per assembly quantity, example: [1.0, 3.0]\n ModifiedDate datetime, -- example: ['2010-02-18 00:00:00.0', '2010-04-20 00:00:00.0']\n PRIMARY KEY (BillOfMaterialsID)\n);\n\nCREATE TABLE ProductDocument (\n ProductID integer, -- example: [317, 318]\n DocumentNode text, -- example: ['/2/1/', '/3/1/']\n ModifiedDate datetime, -- example: ['2013-12-29 13:51:58.0']\n PRIMARY KEY (ProductID, DocumentNode),\n CONSTRAINT fk_productdocument_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productdocument_documentnode FOREIGN KEY (DocumentNode) REFERENCES Document (DocumentNode)\n);\n\nCREATE TABLE Document (\n DocumentNode text, -- example: ['/', '/1/']\n Title text, -- example: ['Documents', 'Overview']\n FileExtension text, -- example: ['.doc']\n rowguid text, -- example: ['26A266F1-1D23-40E2-AF48-6AB8D954FE37', '27CF33AF-C338-4842-966C-75CA11AAA6A3']\n PRIMARY KEY (DocumentNode)\n);\n\nCREATE TABLE SalesTaxRate (\n SalesTaxRateID integer, -- example: [1, 4]\n StateProvinceID integer, -- example: [1, 6]\n Name text, -- example: ['Canadian GST + Alberta Provincial Tax', 'Canadian GST + Ontario Provincial Tax']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (SalesTaxRateID),\n CONSTRAINT fk_salestaxrate_stateprovinceid FOREIGN KEY (StateProvinceID) REFERENCES StateProvince (StateProvinceID)\n);\n\nCREATE TABLE SalesTerritoryHistory (\n BusinessEntityID integer, -- example: [275, 276]\n TerritoryID integer, -- example: [2, 3]\n StartDate datetime, -- example: ['2011-05-31 00:00:00.0', '2012-11-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, TerritoryID, StartDate),\n CONSTRAINT fk_salesterritoryhistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID),\n CONSTRAINT fk_salesterritoryhistory_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE Employee (\n BusinessEntityID integer, -- example: [151, 170]\n BirthDate date, -- example: ['1969-01-29', '1971-08-01']\n HireDate date, -- example: ['2009-01-14', '2008-01-31']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2014-12-26 09:17:08.0']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_employee_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE Product (\n ProductID integer, -- example: [921, 351]\n Name text, -- example: ['AWC Logo Cap', 'Adjustable Race']\n ProductNumber text, -- example: ['AR-5381', 'BA-8327']\n FinishedGoodsFlag integer, -- example: [0, 1]\n Color text, -- example: ['Yellow', 'Black', 'Silver']\n ReorderPoint integer, -- example: [750, 600]\n StandardCost real, -- example: [0.0, 98.77]\n SizeUnitMeasureCode text, -- example: ['CM']\n Class text, -- example: ['L', 'M']\n SellStartDate datetime, -- example: ['2008-04-30 00:00:00.0', '2011-05-31 00:00:00.0']\n rowguid text, -- example: ['01A8C3FC-ED52-458E-A634-D5B6E2ACCFED', '01C901E3-4323-48ED-AB9E-9BFDA28BDEF6']\n PRIMARY KEY (ProductID)\n);\n\nCREATE TABLE Address (\n AddressID integer, -- example: [18089, 23192]\n PRIMARY KEY (AddressID)\n);\n\nCREATE TABLE SpecialOfferProduct (\n SpecialOfferID integer, -- example: [1, 2]\n ProductID integer, -- example: [680, 706]\n rowguid text, -- example: ['0020931C-087C-42F8-B441-EBE3D3B5F51E', '00365938-3422-494E-B92E-C00AFD691469']\n PRIMARY KEY (SpecialOfferID, ProductID),\n CONSTRAINT fk_specialofferproduct_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOffer (SpecialOfferID),\n CONSTRAINT fk_specialofferproduct_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ProductCostHistory (\n ProductID integer, -- example: [707, 708]\n StartDate date, -- example: ['2011-05-31 00:00:00.0', '2012-05-30 00:00:00.0']\n PRIMARY KEY (ProductID, StartDate),\n CONSTRAINT fk_productcosthistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE CountryRegionCurrency (\n CountryRegionCode text, -- example: ['AE', 'AR']\n CurrencyCode text, -- example: ['AED', 'ARS']\n PRIMARY KEY (CountryRegionCode, CurrencyCode),\n CONSTRAINT fk_countryregioncurrency_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode),\n CONSTRAINT fk_countryregioncurrency_currencycode FOREIGN KEY (CurrencyCode) REFERENCES Currency (CurrencyCode)\n);\n\nCREATE TABLE SpecialOffer (\n SpecialOfferID integer, -- example: [1, 15]\n Category text, -- example: ['No Discount', 'Reseller']\n EndDate datetime, -- example: ['2014-11-30 00:00:00.0', '2014-05-30 00:00:00.0']\n PRIMARY KEY (SpecialOfferID)\n);\n\nCREATE TABLE StateProvince (\n StateProvinceID integer, -- example: [103, 101]\n Name text, -- example: ['Ain', 'Aisne']\n rowguid text, -- example: ['00723E00-C976-401D-A92B-E582DF3D6E01', '01CEC802-20CE-4F96-B475-2AD263CEA9D0']\n PRIMARY KEY (StateProvinceID)\n);\n\nCREATE TABLE Store (\n BusinessEntityID integer, -- example: [630, 956]\n Name text, -- example: ['Next-Door Bike Store', 'Professional Sales and Service']\n SalesPersonID integer, -- example: [279, 276]\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_store_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_store_salespersonid FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE UnitMeasure (\n UnitMeasureCode text, -- example: ['BOX', 'BTL']\n Name text, -- example: ['Bottle', 'Boxes']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (UnitMeasureCode)\n);\n\nCREATE TABLE Department (\n DepartmentID integer, -- example: [12, 1]\n Name text, -- example: ['Document Control', 'Engineering']\n PRIMARY KEY (DepartmentID)\n);\n\nCREATE TABLE Location (\n LocationID integer, -- example: [30, 60]\n Name text, -- example: ['Debur and Polish', 'Final Assembly']\n CostRate real, -- example: [0.0, 22.5]\n PRIMARY KEY (LocationID)\n);\n\nCREATE TABLE EmailAddress (\n BusinessEntityID integer, -- example: [1, 2]\n EmailAddressID integer, -- example: [1, 2]\n ModifiedDate datetime, -- example: ['2009-01-07 00:00:00.0', '2008-01-24 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, EmailAddressID),\n CONSTRAINT fk_emailaddress_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Person (BusinessEntityID)\n);\n\nCREATE TABLE TransactionHistory (\n TransactionID integer, -- example: [100000, 100001]\n ProductID integer, -- example: [784, 794]\n TransactionType text, -- example: ['W', 'S']\n ModifiedDate datetime, -- example: ['2013-07-31 00:00:00.0', '2013-08-01 00:00:00.0']\n PRIMARY KEY (TransactionID),\n CONSTRAINT fk_transactionhistory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE EmployeeDepartmentHistory (\n BusinessEntityID integer, -- example: [1, 2]\n DepartmentID integer, -- example: [16, 1]\n ShiftID integer, -- example: [1, 3]\n StartDate date, -- example: ['2009-01-14', '2008-01-31']\n EndDate date, -- example: ['2010-05-30', '2009-07-14']\n ModifiedDate datetime, -- example: ['2009-01-13 00:00:00.0', '2008-01-30 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, DepartmentID, ShiftID, StartDate)\n);\n\nCREATE TABLE SalesPersonQuotaHistory (\n BusinessEntityID integer, -- example: [274, 275]\n QuotaDate datetime, -- example: ['2011-05-31 00:00:00.0', '2011-08-31 00:00:00.0']\n rowguid text, -- example: ['00F2F9F8-5158-4436-B134-7E0C462289E5', '0103899F-618C-4478-90BB-815B20856F35']\n PRIMARY KEY (BusinessEntityID, QuotaDate),\n CONSTRAINT fk_salespersonquotahistory_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES SalesPerson (BusinessEntityID)\n);\n\nCREATE TABLE ProductProductPhoto (\n ProductID integer, -- example: [1, 2]\n ProductPhotoID integer, -- example: [1, 160]\n `Primary` integer, -- example: [1]\n PRIMARY KEY (ProductID, ProductPhotoID),\n CONSTRAINT fk_productproductphoto_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productproductphoto_productphotoid FOREIGN KEY (ProductPhotoID) REFERENCES ProductPhoto (ProductPhotoID)\n);\n\nCREATE TABLE ProductInventory (\n ProductID integer, -- example: [1, 2]\n LocationID integer, -- example: [1, 6]\n Shelf text, -- example: ['A', 'B']\n rowguid text, -- example: ['47A24246-6C43-48EB-968F-025738A8A410', 'D4544D7D-CAF5-46B3-AB22-5718DCC26B5E']\n PRIMARY KEY (ProductID, LocationID),\n CONSTRAINT fk_productinventory_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID),\n CONSTRAINT fk_productinventory_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE Shift (\n ShiftID integer, -- example: [1, 2]\n Name text, -- example: ['Day', 'Evening']\n PRIMARY KEY (ShiftID)\n);\n\nCREATE TABLE Culture (\n CultureID text, -- example: ['ar', 'en']\n Name text, -- example: ['Arabic', 'Chinese']\n ModifiedDate datetime, -- example: ['2008-04-30 00:00:00.0']\n PRIMARY KEY (CultureID)\n);\n\nCREATE TABLE SalesTerritory (\n TerritoryID integer, -- example: [2, 10]\n Name text, -- example: ['Australia', 'Canada']\n CountryRegionCode text, -- example: ['US', 'CA']\n `Group` text, -- example: ['North America', 'Europe']\n SalesLastYear real, -- example: [3298694.4938, 3607148.9371]\n rowguid text, -- example: ['00FB7309-96CC-49E2-8363-0A1BA72486F2', '05FC7E1F-2DEA-414E-9ECD-09D150516FB5']\n PRIMARY KEY (TerritoryID),\n CONSTRAINT fk_salesterritory_countryregioncode FOREIGN KEY (CountryRegionCode) REFERENCES CountryRegion (CountryRegionCode)\n);\n\nCREATE TABLE CurrencyRate (\n CurrencyRateID integer, -- example: [1, 2]\n ToCurrencyCode text, -- example: ['ARS', 'AUD']\n PRIMARY KEY (CurrencyRateID)\n);\n\nCREATE TABLE BusinessEntityContact (\n BusinessEntityID integer, -- example: [292, 294]\n PersonID integer, -- example: [291, 293]\n ContactTypeID integer, -- example: [11, 14]\n PRIMARY KEY (BusinessEntityID, PersonID, ContactTypeID),\n CONSTRAINT fk_businessentitycontact_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_personid FOREIGN KEY (PersonID) REFERENCES Person (BusinessEntityID),\n CONSTRAINT fk_businessentitycontact_contacttypeid FOREIGN KEY (ContactTypeID) REFERENCES ContactType (ContactTypeID)\n);\n\nCREATE TABLE Person (\n BusinessEntityID integer, -- example: [14617, 18779]\n Title text, -- example: ['Ms.', 'Mr.']\n FirstName text, -- example: ['Ken', 'Terri']\n MiddleName text, -- example: ['J', 'Lee']\n Demographics text, -- example: ['<IndividualSurvey xmlns=\"http://schemas.']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_person_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES BusinessEntity (BusinessEntityID)\n);\n\nCREATE TABLE ProductReview (\n ProductReviewID integer, -- example: [1, 2]\n ProductID integer, -- example: [709, 937]\n ReviewerName text, -- example: ['John Smith', 'David']\n ReviewDate datetime, -- example: ['2013-09-18 00:00:00.0', '2013-11-13 00:00:00.0']\n Comments text, -- example: [\"I can't believe I'm singing the praises \", 'A little on the heavy side, but overall ']\n PRIMARY KEY (ProductReviewID),\n CONSTRAINT fk_productreview_productid FOREIGN KEY (ProductID) REFERENCES Product (ProductID)\n);\n\nCREATE TABLE ContactType (\n ContactTypeID integer, -- example: [1, 2]\n Name text, -- example: ['Accounting Manager', 'Assistant Sales Agent']\n PRIMARY KEY (ContactTypeID)\n);\n\nCREATE TABLE SalesOrderDetail (\n SalesOrderID integer, -- example: [43659, 43660]\n SalesOrderDetailID integer, -- example: [54351, 90855]\n ProductID integer, -- example: [776, 777]\n SpecialOfferID integer, -- example: [1, 2]\n LineTotal real, -- example: [2025.0, 6075.0]\n PRIMARY KEY (SalesOrderDetailID),\n CONSTRAINT fk_salesorderdetail_salesorderid FOREIGN KEY (SalesOrderID) REFERENCES SalesOrderHeader (SalesOrderID),\n CONSTRAINT fk_salesorderdetail_productid FOREIGN KEY (ProductID) REFERENCES SpecialOfferProduct (ProductID),\n CONSTRAINT fk_salesorderdetail_specialofferid FOREIGN KEY (SpecialOfferID) REFERENCES SpecialOfferProduct (SpecialOfferID)\n);\n\nCREATE TABLE SalesPerson (\n BusinessEntityID integer, -- example: [287, 275]\n TerritoryID integer, -- example: [2, 4]\n rowguid text, -- example: ['1DD1F689-DF74-4149-8600-59555EEF154B', '1E0A7274-3064-4F58-88EE-4C6586C87169']\n PRIMARY KEY (BusinessEntityID),\n CONSTRAINT fk_salesperson_businessentityid FOREIGN KEY (BusinessEntityID) REFERENCES Employee (BusinessEntityID),\n CONSTRAINT fk_salesperson_territoryid FOREIGN KEY (TerritoryID) REFERENCES SalesTerritory (TerritoryID)\n);\n\nCREATE TABLE CountryRegion (\n CountryRegionCode text, -- example: ['AD', 'AE']\n Name text, -- example: ['Afghanistan', 'Albania']\n PRIMARY KEY (CountryRegionCode)\n);\n\nCREATE TABLE EmployeePayHistory (\n BusinessEntityID integer, -- example: [1, 2]\n RateChangeDate datetime, -- example: ['2009-01-14 00:00:00.0', '2008-01-31 00:00:00.0']\n ModifiedDate datetime, -- example: ['2014-06-30 00:00:00.0', '2007-11-21 00:00:00.0']\n PRIMARY KEY (BusinessEntityID, RateChangeDate)\n);\n\nCREATE TABLE WorkOrderRouting (\n WorkOrderID integer, -- example: [13, 14]\n ProductID integer, -- example: [747, 748]\n OperationSequence integer, -- example: [1, 2]\n LocationID integer, -- example: [10, 20]\n ActualEndDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n ActualResourceHrs real, -- Actual Resource Hours, example: [4.1, 3.5]\n ActualCost real, -- example: [92.25, 87.5]\n ModifiedDate datetime, -- example: ['2011-06-19 00:00:00.0', '2011-06-15 00:00:00.0']\n PRIMARY KEY (WorkOrderID, ProductID, OperationSequence),\n CONSTRAINT fk_workorderrouting_workorderid FOREIGN KEY (WorkOrderID) REFERENCES WorkOrder (WorkOrderID),\n CONSTRAINT fk_workorderrouting_locationid FOREIGN KEY (LocationID) REFERENCES Location (LocationID)\n);\n\nCREATE TABLE JobCandidate (\n JobCandidateID integer, -- example: [2, 3]\n BusinessEntityID integer, -- example: [274, 212]\n PRIMARY KEY (JobCandidateID)\n);\n\nCREATE TABLE BusinessEntity (\n BusinessEntityID integer, -- example: [8722, 4079]\n ModifiedDate datetime, -- example: ['2017-12-13 13:20:24.0', '2017-12-13 13:20:25.0']\n PRIMARY KEY (BusinessEntityID)\n);\n\nCREATE TABLE ProductModelProductDescriptionCulture (\n ProductModelID integer, -- example: [1, 2]\n ProductDescriptionID integer, -- example: [1199, 1467]\n CultureID text, -- example: ['en', 'ar']\n PRIMARY KEY (ProductModelID, ProductDescriptionID, CultureID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productmodelid FOREIGN KEY (ProductModelID) REFERENCES ProductModel (ProductModelID),\n CONSTRAINT fk_productmodelproductdescriptionculture_productdescriptionid FOREIGN KEY (ProductDescriptionID) REFERENCES ProductDescription (ProductDescriptionID),\n CONSTRAINT fk_productmodelproductdescriptionculture_cultureid FOREIGN KEY (CultureID) REFERENCES Culture (CultureID)\n);\n\nCREATE TABLE TransactionHistoryArchive (\n TransactionID integer, -- example: [1, 2]\n ProductID integer, -- example: [1, 359]\n TransactionType text, -- example: ['P', 'S']\n ModifiedDate datetime, -- example: ['2011-04-16 00:00:00.0', '2011-04-30 00:00:00.0']\n PRIMARY KEY (TransactionID)\n);\nThis schema describes the database's structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints.\n\nQuestion:\nList all products with the color yellow.\n\nInstructions:\n- Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more.\n- The generated query should return all of the information asked in the question without any missing or extra information.\n- Before generating the final SQL query, please think through the steps of how to write the query.\n\nOutput Format:\nIn your answer, please enclose the generated SQL query in a code block:\n```sql\n-- Your SQL query\n```\n\nTake a deep breath and think step by step to find the correct SQL query.\n", "split": "train" }