input
stringlengths
122
2.7k
output
stringlengths
24
805
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT T3.EmailAddress FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmailAddress AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.Gender = 'F' AND T1.MaritalStatus = 'S';
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
SELECT T1.Color FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductID = 709 OR 937 OR 798;
[INST] Here is a database schema: SalesPerson : BusinessEntityID [ INTEGER ] primary_key SalesPerson.BusinessEntityID = Employee.BusinessEntityID TerritoryID [ INTEGER ] SalesPerson.TerritoryID = SalesTerritory.TerritoryID SalesQuota [ REAL ] Bonus [ REAL ] CommissionPct [ REAL ] SalesYTD [ REAL ] SalesLastYear [ REAL ...
SELECT SUM(T1.SalesQuota) FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.BusinessEntityID = 275 AND STRFTIME('%Y', QuotaDate) = '2013';
[INST] Here is a database schema: SalesPerson : BusinessEntityID [ INTEGER ] primary_key SalesPerson.BusinessEntityID = Employee.BusinessEntityID TerritoryID [ INTEGER ] SalesPerson.TerritoryID = SalesTerritory.TerritoryID SalesQuota [ REAL ] Bonus [ REAL ] CommissionPct [ REAL ] SalesYTD [ REAL ] SalesLastYear [ REAL ...
SELECT DISTINCT T1.BusinessEntityID FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.QuotaDate) = '2013' AND T1.SalesQuota < T1.SalesLastYear;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT CAST(SUM(CASE WHEN T1.Gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT CAST(SUM(CASE WHEN T1.MaritalStatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.MaritalStatus = 'S' THEN 1 ELSE 0 END) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'EM';
[INST] Here is a database schema: SalesPerson : BusinessEntityID [ INTEGER ] primary_key SalesPerson.BusinessEntityID = Employee.BusinessEntityID TerritoryID [ INTEGER ] SalesPerson.TerritoryID = SalesTerritory.TerritoryID SalesQuota [ REAL ] Bonus [ REAL ] CommissionPct [ REAL ] SalesYTD [ REAL ] SalesLastYear [ REAL ...
SELECT SUM(T1.Bonus) , CAST(SUM(T1.Bonus) AS REAL) * 100 / SUM(T1.SalesQuota) FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.QuotaDate) = '2013';
[INST] Here is a database schema: CreditCard : CreditCardID [ INTEGER ] primary_key CardType [ TEXT ] CardNumber [ TEXT ] ExpMonth [ INTEGER ] ExpYear [ INTEGER ] ModifiedDate [ DATETIME ] Please write me a SQL statement that answers the following question: How many types of credit cards are there and how many are vis...
SELECT COUNT(CardNumber) FROM CreditCard WHERE CardType = 'vista';
[INST] Here is a database schema: Product : ProductID [ INTEGER ] primary_key Name [ TEXT ] ProductNumber [ TEXT ] MakeFlag [ INTEGER ] FinishedGoodsFlag [ INTEGER ] Color [ TEXT ] SafetyStockLevel [ INTEGER ] ReorderPoint [ INTEGER ] StandardCost [ REAL ] ListPrice [ REAL ] Size [ TEXT ] SizeUnitMeasureCode [ TEXT ] W...
SELECT Name FROM Product WHERE ProductID = 475;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT COUNT(BusinessEntityID) FROM Employee WHERE MaritalStatus = 's' AND BirthDate < '1980-1-1';
[INST] Here is a database schema: Store : BusinessEntityID [ INTEGER ] primary_key Store.BusinessEntityID = BusinessEntity.BusinessEntityID Name [ TEXT ] SalesPersonID [ INTEGER ] Store.SalesPersonID = SalesPerson.BusinessEntityID Demographics [ TEXT ] rowguid [ TEXT ] ModifiedDate [ DATETIME ] Please write me a SQL s...
SELECT Name FROM Store WHERE SalesPersonID = 277;
[INST] Here is a database schema: TransactionHistory : TransactionID [ INTEGER ] primary_key ProductID [ INTEGER ] TransactionHistory.ProductID = Product.ProductID ReferenceOrderID [ INTEGER ] ReferenceOrderLineID [ INTEGER ] TransactionDate [ DATETIME ] TransactionType [ TEXT ] Quantity [ INTEGER ] ActualCost [ REAL ]...
SELECT SUM(Quantity) FROM TransactionHistory WHERE TransactionDate LIKE '2013-08%' AND TransactionType = 'S' AND ProductID = 989;
[INST] Here is a database schema: CreditCard : CreditCardID [ INTEGER ] primary_key CardType [ TEXT ] CardNumber [ TEXT ] ExpMonth [ INTEGER ] ExpYear [ INTEGER ] ModifiedDate [ DATETIME ] Please write me a SQL statement that answers the following question: List all of the credit cards that had expired by 2007. [/INST...
SELECT CardNumber FROM CreditCard WHERE ExpYear < 2007;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT T2.Rate FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) = 20;
[INST] Here is a database schema: SalesTerritory : TerritoryID [ INTEGER ] primary_key Name [ TEXT ] CountryRegionCode [ TEXT ] SalesTerritory.CountryRegionCode = CountryRegion.CountryRegionCode Group [ TEXT ] SalesYTD [ REAL ] SalesLastYear [ REAL ] CostYTD [ REAL ] CostLastYear [ REAL ] rowguid [ TEXT ] ModifiedDate ...
SELECT T2.Name FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T1.BusinessEntityID = 277;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Vice President of Production';
[INST] Here is a database schema: Shift : ShiftID [ INTEGER ] primary_key Name [ TEXT ] StartTime [ TEXT ] EndTime [ TEXT ] ModifiedDate [ DATETIME ] Department : DepartmentID [ INTEGER ] primary_key Name [ TEXT ] GroupName [ TEXT ] ModifiedDate [ DATETIME ] EmployeeDepartmentHistory : BusinessEntityID [ INTEGER ] Depa...
SELECT COUNT(T2.BusinessEntityID) FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN Shift AS T3 ON T2.ShiftId = T3.ShiftId WHERE T1.Name = 'Information Services' AND T3.Name = 'Evening';
[INST] Here is a database schema: Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.BusinessEntityID = BusinessEntity.BusinessEntityID AccountNumber [ TEXT ] Name [ TEXT ] CreditRating [ INTEGER ] PreferredVendorStatus [ INTEGER ] ActiveFlag [ INTEGER ] PurchasingWebServiceURL [ TEXT ] ModifiedDate [ DATETIME ] ...
SELECT T2.PurchaseOrderID FROM Vendor AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.BusinessEntityID = T2.VendorID WHERE T1.CreditRating = 5;
[INST] Here is a database schema: PhoneNumberType : PhoneNumberTypeID [ INTEGER ] primary_key Name [ TEXT ] ModifiedDate [ DATETIME ] Please write me a SQL statement that answers the following question: Is the phone number "114-555-0100" a work number or a home number? [/INST] [/INST]
SELECT T2.Name FROM PersonPhone AS T1 INNER JOIN PhoneNumberType AS T2 ON T1.PhoneNumberTypeID = T2.PhoneNumberTypeID WHERE T1.PhoneNumber = '114-555-0100';
[INST] Here is a database schema: ShipMethod : ShipMethodID [ INTEGER ] primary_key Name [ TEXT ] ShipBase [ REAL ] ShipRate [ REAL ] rowguid [ TEXT ] ModifiedDate [ DATETIME ] PurchaseOrderHeader : PurchaseOrderID [ INTEGER ] primary_key RevisionNumber [ INTEGER ] Status [ INTEGER ] EmployeeID [ INTEGER ] PurchaseOrde...
SELECT SUM(t2.freight) FROM ShipMethod AS t1 INNER JOIN PurchaseOrderHeader AS t2 ON t1.shipmethodid = t2.shipmethodid WHERE t1.name = 'cargo transport 5' AND t2.orderdate = '2011-12-14';
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT COUNT(T2.TotalDue) FROM Person AS T1 INNER JOIN SalesOrderHeader AS T2 ON T1.ModifiedDate = T2.DueDate WHERE T1.FirstName = 'David' AND T1.MiddleName = 'R' AND T1.LastName = 'Campbell' AND T1.PersonType = 'SP';
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT T3.EmailAddress FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmailAddress AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.JobTitle = 'Facilities Manager';
[INST] Here is a database schema: SalesTerritory : TerritoryID [ INTEGER ] primary_key Name [ TEXT ] CountryRegionCode [ TEXT ] SalesTerritory.CountryRegionCode = CountryRegion.CountryRegionCode Group [ TEXT ] SalesYTD [ REAL ] SalesLastYear [ REAL ] CostYTD [ REAL ] CostLastYear [ REAL ] rowguid [ TEXT ] ModifiedDate ...
SELECT COUNT(T2.CustomerID) FROM SalesTerritory AS T1 INNER JOIN Customer AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T1.Name = 'Canada';
[INST] Here is a database schema: Address : AddressID [ INTEGER ] primary_key AddressLine1 [ TEXT ] AddressLine2 [ TEXT ] City [ TEXT ] StateProvinceID [ INTEGER ] PostalCode [ TEXT ] SpatialLocation [ TEXT ] rowguid [ TEXT ] ModifiedDate [ DATETIME ] SalesOrderHeader : SalesOrderID [ INTEGER ] primary_key RevisionNumb...
SELECT T1.ShipToAddressID FROM SalesOrderHeader AS T1 INNER JOIN Address AS T2 ON T1.BillToAddressID = T2.AddressID WHERE T1.SalesOrderID = 43873 GROUP BY T1.ShipToAddressID;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT T2.FirstName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.SickLeaveHours > 65;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle LIKE 'Production Technician%' AND T2.Rate < ( SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ...
[INST] Here is a database schema: SalesTerritory : TerritoryID [ INTEGER ] primary_key Name [ TEXT ] CountryRegionCode [ TEXT ] SalesTerritory.CountryRegionCode = CountryRegion.CountryRegionCode Group [ TEXT ] SalesYTD [ REAL ] SalesLastYear [ REAL ] CostYTD [ REAL ] CostLastYear [ REAL ] rowguid [ TEXT ] ModifiedDate ...
SELECT CAST(SUM(CASE WHEN T2.Name = 'United Kingdom' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.SalesOrderID) FROM SalesOrderHeader AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID;
[INST] Please write me a SQL statement that answers the following question: When is the modified date of the phone number "1500 555-0143"? [/INST] [/INST]
SELECT ModifiedDate FROM PersonPhone WHERE PhoneNumber = '1 (11) 500 555-0143';
[INST] Here is a database schema: SalesPerson : BusinessEntityID [ INTEGER ] primary_key SalesPerson.BusinessEntityID = Employee.BusinessEntityID TerritoryID [ INTEGER ] SalesPerson.TerritoryID = SalesTerritory.TerritoryID SalesQuota [ REAL ] Bonus [ REAL ] CommissionPct [ REAL ] SalesYTD [ REAL ] SalesLastYear [ REAL ...
SELECT BusinessEntityID FROM SalesPerson ORDER BY SalesYTD DESC LIMIT 1;
[INST] Here is a database schema: Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.BusinessEntityID = BusinessEntity.BusinessEntityID AccountNumber [ TEXT ] Name [ TEXT ] CreditRating [ INTEGER ] PreferredVendorStatus [ INTEGER ] ActiveFlag [ INTEGER ] PurchasingWebServiceURL [ TEXT ] ModifiedDate [ DATETIME ] ...
SELECT Name FROM Vendor WHERE ActiveFlag = 1;
[INST] Here is a database schema: Customer : CustomerID [ INTEGER ] primary_key PersonID [ INTEGER ] Customer.PersonID = Person.BusinessEntityID StoreID [ INTEGER ] Customer.StoreID = Store.BusinessEntityID TerritoryID [ INTEGER ] Customer.TerritoryID = SalesTerritory.TerritoryID AccountNumber [ TEXT ] rowguid [ TEXT ]...
SELECT TerritoryID FROM Customer WHERE ModifiedDate < '2014-12-09' GROUP BY TerritoryID ORDER BY COUNT(TerritoryID) DESC LIMIT 1;
[INST] Here is a database schema: PurchaseOrderHeader : PurchaseOrderID [ INTEGER ] primary_key RevisionNumber [ INTEGER ] Status [ INTEGER ] EmployeeID [ INTEGER ] PurchaseOrderHeader.EmployeeID = Employee.BusinessEntityID VendorID [ INTEGER ] PurchaseOrderHeader.VendorID = Vendor.BusinessEntityID ShipMethodID [ INTEG...
SELECT SUM(TotalDue) FROM PurchaseOrderHeader WHERE OrderDate LIKE '2013-05-29%';
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT FirstName FROM Person WHERE PersonType = 'VC' GROUP BY FirstName ORDER BY COUNT(*) DESC LIMIT 1;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 USING (BusinessEntityID) WHERE T1.JobTitle = 'Production Technician - WC50' GROUP BY T2.FirstName, T2.MiddleName, T2.LastName;
[INST] Here is a database schema: SalesOrderDetail : SalesOrderID [ INTEGER ] SalesOrderDetail.SalesOrderID = SalesOrderHeader.SalesOrderID SalesOrderDetailID [ INTEGER ] primary_key CarrierTrackingNumber [ TEXT ] OrderQty [ INTEGER ] ProductID [ INTEGER ] SalesOrderDetail.ProductID = SpecialOfferProduct.ProductID Spec...
SELECT COUNT(OrderQty) FROM SalesOrderDetail WHERE ProductID IN ( SELECT ProductID FROM Product WHERE Name = 'Minipump' );
[INST] Here is a database schema: PersonCreditCard : BusinessEntityID [ INTEGER ] PersonCreditCard.BusinessEntityID = Person.BusinessEntityID CreditCardID [ INTEGER ] PersonCreditCard.CreditCardID = CreditCard.CreditCardID ModifiedDate [ DATETIME ] CreditCard : CreditCardID [ INTEGER ] primary_key CardType [ TEXT ] Car...
SELECT T2.BusinessEntityID FROM CreditCard AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID WHERE T1.CardNumber = 11113366963373;
[INST] Here is a database schema: BusinessEntityAddress : BusinessEntityID [ INTEGER ] BusinessEntityAddress.BusinessEntityID = BusinessEntity.BusinessEntityID AddressID [ INTEGER ] BusinessEntityAddress.AddressID = Address.AddressID AddressTypeID [ INTEGER ] BusinessEntityAddress.AddressTypeID = AddressType.AddressTyp...
SELECT T3.City, T3.AddressLine1 FROM BusinessEntityAddress AS T1 INNER JOIN AddressType AS T2 ON T1.AddressTypeID = T2.AddressTypeID INNER JOIN Address AS T3 ON T1.AddressID = T3.AddressID WHERE T1.BusinessEntityID = 5555 AND T2.Name = 'Home';
[INST] Here is a database schema: SpecialOfferProduct : SpecialOfferID [ INTEGER ] SpecialOfferProduct.SpecialOfferID = SpecialOffer.SpecialOfferID ProductID [ INTEGER ] SpecialOfferProduct.ProductID = Product.ProductID rowguid [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] primary_key Name [ TEXT ]...
SELECT T2.Name FROM SpecialOfferProduct AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.SpecialOfferID = 15;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT T3.CreditCardID 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 = 'Michelle' AND T1.MiddleName = 'E' AND T1.LastName = 'Cox';
[INST] Here is a database schema: SalesReason : SalesReasonID [ INTEGER ] primary_key Name [ TEXT ] ReasonType [ TEXT ] ModifiedDate [ DATETIME ] SalesOrderHeaderSalesReason : SalesOrderID [ INTEGER ] SalesOrderHeaderSalesReason.SalesOrderID = SalesOrderHeader.SalesOrderID SalesReasonID [ INTEGER ] SalesOrderHeaderSale...
SELECT T2.Name FROM SalesOrderHeaderSalesReason AS T1 INNER JOIN SalesReason AS T2 ON T1.SalesReasonID = T2.SalesReasonID WHERE T1.SalesOrderID = 51883;
[INST] Here is a database schema: CreditCard : CreditCardID [ INTEGER ] primary_key CardType [ TEXT ] CardNumber [ TEXT ] ExpMonth [ INTEGER ] ExpYear [ INTEGER ] ModifiedDate [ DATETIME ] SalesOrderHeader : SalesOrderID [ INTEGER ] primary_key RevisionNumber [ INTEGER ] OrderDate [ DATETIME ] DueDate [ DATETIME ] Ship...
SELECT T2.CardNumber FROM SalesOrderHeader AS T1 INNER JOIN CreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID WHERE T1.SalesOrderID = 45793;
[INST] Here is a database schema: SalesTerritory : TerritoryID [ INTEGER ] primary_key Name [ TEXT ] CountryRegionCode [ TEXT ] SalesTerritory.CountryRegionCode = CountryRegion.CountryRegionCode Group [ TEXT ] SalesYTD [ REAL ] SalesLastYear [ REAL ] CostYTD [ REAL ] CostLastYear [ REAL ] rowguid [ TEXT ] ModifiedDate ...
SELECT T2.BusinessEntityID FROM SalesTerritory AS T1 INNER JOIN SalesPerson AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T1.Name = 'Northwest' AND T1.CountryRegionCode = 'US';
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT T1.BusinessEntityID FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle LIKE 'Production Technician%' ORDER BY T2.Rate DESC LIMIT 1;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.TerritoryID = 9;
[INST] Here is a database schema: SpecialOffer : SpecialOfferID [ INTEGER ] primary_key Description [ TEXT ] DiscountPct [ REAL ] Type [ TEXT ] Category [ TEXT ] StartDate [ DATETIME ] EndDate [ DATETIME ] MinQty [ INTEGER ] MaxQty [ INTEGER ] rowguid [ TEXT ] ModifiedDate [ DATETIME ] SpecialOfferProduct : SpecialOffe...
SELECT T2.Description FROM SpecialOfferProduct AS T1 INNER JOIN SpecialOffer AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID WHERE T1.ProductID = 762;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID GROUP BY T1.Gender;
[INST] Here is a database schema: Shift : ShiftID [ INTEGER ] primary_key Name [ TEXT ] StartTime [ TEXT ] EndTime [ TEXT ] ModifiedDate [ DATETIME ] EmployeeDepartmentHistory : BusinessEntityID [ INTEGER ] DepartmentID [ INTEGER ] ShiftID [ INTEGER ] StartDate [ DATE ] EndDate [ DATE ] ModifiedDate [ DATETIME ] Pleas...
SELECT CAST(SUM(CASE WHEN T1.Name = 'Night' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.BusinessEntityID) FROM Shift AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.ShiftId = T2.ShiftId;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT COUNT(BusinessEntityID) FROM Employee WHERE MaritalStatus = 'M' AND STRFTIME('%Y', BirthDate) < '1960' AND Gender = 'M';
[INST] Here is a database schema: Product : ProductID [ INTEGER ] primary_key Name [ TEXT ] ProductNumber [ TEXT ] MakeFlag [ INTEGER ] FinishedGoodsFlag [ INTEGER ] Color [ TEXT ] SafetyStockLevel [ INTEGER ] ReorderPoint [ INTEGER ] StandardCost [ REAL ] ListPrice [ REAL ] Size [ TEXT ] SizeUnitMeasureCode [ TEXT ] W...
SELECT Name FROM Product ORDER BY ListPrice DESC LIMIT 5;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT MIN(HireDate) FROM Employee WHERE JobTitle = 'Accountant';
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT JobTitle FROM Employee WHERE STRFTIME('%Y', HireDate) = '2007' GROUP BY HireDate ORDER BY COUNT(JobTitle) DESC LIMIT 1;
[INST] Here is a database schema: ProductVendor : ProductID [ INTEGER ] ProductVendor.ProductID = Product.ProductID BusinessEntityID [ INTEGER ] ProductVendor.BusinessEntityID = Vendor.BusinessEntityID AverageLeadTime [ INTEGER ] StandardPrice [ REAL ] LastReceiptCost [ REAL ] LastReceiptDate [ DATETIME ] MinOrderQty [...
SELECT LastReceiptCost - StandardPrice FROM ProductVendor ORDER BY StandardPrice DESC LIMIT 1;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT COUNT(T3.Name) 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 T1.FirstName = 'Sheela' AND T1.LastName = 'Word' AND STRFTIME('%Y', T3.ModifiedDate) BETWEEN '2011' AND '2012';
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT AVG(2009 - STRFTIME('%Y', T2.BirthDate)) FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.PersonType = 'SP';
[INST] Here is a database schema: Department : DepartmentID [ INTEGER ] primary_key Name [ TEXT ] GroupName [ TEXT ] ModifiedDate [ DATETIME ] EmployeeDepartmentHistory : BusinessEntityID [ INTEGER ] DepartmentID [ INTEGER ] ShiftID [ INTEGER ] StartDate [ DATE ] EndDate [ DATE ] ModifiedDate [ DATETIME ] Please write...
SELECT T2.GroupName FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID GROUP BY T2.GroupName ORDER BY COUNT(T1.BusinessEntityID) LIMIT 1;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
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;
[INST] Here is a database schema: Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.BusinessEntityID = BusinessEntity.BusinessEntityID AccountNumber [ TEXT ] Name [ TEXT ] CreditRating [ INTEGER ] PreferredVendorStatus [ INTEGER ] ActiveFlag [ INTEGER ] PurchasingWebServiceURL [ TEXT ] ModifiedDate [ DATETIME ] ...
SELECT T1.UnitPrice, T3.Name FROM PurchaseOrderDetail AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID INNER JOIN Vendor AS T3 ON T2.VendorID = T3.BusinessEntityID ORDER BY T1.UnitPrice LIMIT 1;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
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;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
SELECT T2.JobTitle, T1.Rate, T3.FirstName, T3.MiddleName, T3.LastName 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 T1.Rate DESC LIMIT 9, 1;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
SELECT T1.ListPrice - T1.StandardCost, T1.Name FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ReviewerName = 'John Smith' ORDER BY T2.Rating DESC LIMIT 1;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
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;
[INST] Here is a database schema: Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.BusinessEntityID = BusinessEntity.BusinessEntityID AccountNumber [ TEXT ] Name [ TEXT ] CreditRating [ INTEGER ] PreferredVendorStatus [ INTEGER ] ActiveFlag [ INTEGER ] PurchasingWebServiceURL [ TEXT ] ModifiedDate [ DATETIME ] ...
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;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT 2011 - STRFTIME('%Y', T2.HireDate) FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T1.Status = 1;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
SELECT T1.DaysToManufacture FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Rating = 5 AND T1.Class = 'M' ORDER BY T2.Rating LIMIT 1;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
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;
[INST] Here is a database schema: TransactionHistory : TransactionID [ INTEGER ] primary_key ProductID [ INTEGER ] TransactionHistory.ProductID = Product.ProductID ReferenceOrderID [ INTEGER ] ReferenceOrderLineID [ INTEGER ] TransactionDate [ DATETIME ] TransactionType [ TEXT ] Quantity [ INTEGER ] ActualCost [ REAL ]...
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;
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'F';
[INST] Here is a database schema: ProductSubcategory : ProductSubcategoryID [ INTEGER ] primary_key ProductCategoryID [ INTEGER ] ProductSubcategory.ProductCategoryID = ProductCategory.ProductCategoryID Name [ TEXT ] rowguid [ TEXT ] ModifiedDate [ DATETIME ] Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.Bus...
SELECT DISTINCT T4.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN ProductSubcategory AS T3 ON T1.ProductSubcategoryID = T3.ProductSubcategoryID INNER JOIN Vendor AS T4 ON T2.BusinessEntityID = T4.BusinessEntityID WHERE T1.MakeFlag = 0 AND T1.Style = 'W' AND T3.Name = 'T...
[INST] Here is a database schema: Employee : BusinessEntityID [ INTEGER ] primary_key Employee.BusinessEntityID = Person.BusinessEntityID NationalIDNumber [ TEXT ] LoginID [ TEXT ] OrganizationNode [ TEXT ] OrganizationLevel [ INTEGER ] JobTitle [ TEXT ] BirthDate [ DATE ] MaritalStatus [ TEXT ] Gender [ TEXT ] HireDat...
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;
[INST] Here is a database schema: ShoppingCartItem : ShoppingCartItemID [ INTEGER ] primary_key ShoppingCartID [ TEXT ] Quantity [ INTEGER ] ProductID [ INTEGER ] ShoppingCartItem.ProductID = Product.ProductID DateCreated [ DATETIME ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] primary_key Name [ TEXT ] P...
SELECT T2.Class, T2.ProductLine, T2.ListPrice FROM ShoppingCartItem AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID ORDER BY SUM(Quantity) LIMIT 1;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
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;
[INST] Here is a database schema: Person : BusinessEntityID [ INTEGER ] primary_key Person.BusinessEntityID = BusinessEntity.BusinessEntityID PersonType [ TEXT ] NameStyle [ INTEGER ] Title [ TEXT ] FirstName [ TEXT ] MiddleName [ TEXT ] LastName [ TEXT ] Suffix [ TEXT ] EmailPromotion [ INTEGER ] AdditionalContactInfo...
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;
[INST] Here is a database schema: ShoppingCartItem : ShoppingCartItemID [ INTEGER ] primary_key ShoppingCartID [ TEXT ] Quantity [ INTEGER ] ProductID [ INTEGER ] ShoppingCartItem.ProductID = Product.ProductID DateCreated [ DATETIME ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] primary_key Name [ TEXT ] P...
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;
[INST] Here is a database schema: PurchaseOrderHeader : PurchaseOrderID [ INTEGER ] primary_key RevisionNumber [ INTEGER ] Status [ INTEGER ] EmployeeID [ INTEGER ] PurchaseOrderHeader.EmployeeID = Employee.BusinessEntityID VendorID [ INTEGER ] PurchaseOrderHeader.VendorID = Vendor.BusinessEntityID ShipMethodID [ INTEG...
SELECT T2.OrderQty - T2.ReceivedQty, VendorID FROM PurchaseOrderHeader AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID ORDER BY T2.OrderQty - T2.ReceivedQty DESC LIMIT 1;
[INST] Here is a database schema: BusinessEntityAddress : BusinessEntityID [ INTEGER ] BusinessEntityAddress.BusinessEntityID = BusinessEntity.BusinessEntityID AddressID [ INTEGER ] BusinessEntityAddress.AddressID = Address.AddressID AddressTypeID [ INTEGER ] BusinessEntityAddress.AddressTypeID = AddressType.AddressTyp...
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...
[INST] Here is a database schema: SalesPerson : BusinessEntityID [ INTEGER ] primary_key SalesPerson.BusinessEntityID = Employee.BusinessEntityID TerritoryID [ INTEGER ] SalesPerson.TerritoryID = SalesTerritory.TerritoryID SalesQuota [ REAL ] Bonus [ REAL ] CommissionPct [ REAL ] SalesYTD [ REAL ] SalesLastYear [ REAL ...
SELECT COUNT(BusinessEntityID) FROM SalesPerson WHERE Bonus = 0;
[INST] Here is a database schema: SalesTaxRate : SalesTaxRateID [ INTEGER ] primary_key StateProvinceID [ INTEGER ] SalesTaxRate.StateProvinceID = StateProvince.StateProvinceID TaxType [ INTEGER ] TaxRate [ REAL ] Name [ TEXT ] rowguid [ TEXT ] ModifiedDate [ DATETIME ] Please write me a SQL statement that answers the...
SELECT COUNT(SalesTaxRateID) FROM SalesTaxRate WHERE Name LIKE '%+%';
[INST] Here is a database schema: TransactionHistory : TransactionID [ INTEGER ] primary_key ProductID [ INTEGER ] TransactionHistory.ProductID = Product.ProductID ReferenceOrderID [ INTEGER ] ReferenceOrderLineID [ INTEGER ] TransactionDate [ DATETIME ] TransactionType [ TEXT ] Quantity [ INTEGER ] ActualCost [ REAL ]...
SELECT ActualCost FROM TransactionHistory WHERE TransactionType = 'P' ORDER BY ActualCost DESC LIMIT 1;
[INST] Here is a database schema: SalesOrderHeader : SalesOrderID [ INTEGER ] primary_key RevisionNumber [ INTEGER ] OrderDate [ DATETIME ] DueDate [ DATETIME ] ShipDate [ DATETIME ] Status [ INTEGER ] OnlineOrderFlag [ INTEGER ] SalesOrderNumber [ TEXT ] PurchaseOrderNumber [ TEXT ] AccountNumber [ TEXT ] CustomerID [...
SELECT Status FROM SalesOrderHeader ORDER BY Freight DESC LIMIT 1;
[INST] Here is a database schema: ProductVendor : ProductID [ INTEGER ] ProductVendor.ProductID = Product.ProductID BusinessEntityID [ INTEGER ] ProductVendor.BusinessEntityID = Vendor.BusinessEntityID AverageLeadTime [ INTEGER ] StandardPrice [ REAL ] LastReceiptCost [ REAL ] LastReceiptDate [ DATETIME ] MinOrderQty [...
SELECT COUNT(ProductID) FROM ProductVendor WHERE OnOrderQty = 0;
[INST] Here is a database schema: ProductVendor : ProductID [ INTEGER ] ProductVendor.ProductID = Product.ProductID BusinessEntityID [ INTEGER ] ProductVendor.BusinessEntityID = Vendor.BusinessEntityID AverageLeadTime [ INTEGER ] StandardPrice [ REAL ] LastReceiptCost [ REAL ] LastReceiptDate [ DATETIME ] MinOrderQty [...
SELECT LastReceiptCost - StandardPrice FROM ProductVendor ORDER BY LastReceiptCost - StandardPrice DESC LIMIT 1;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Please write me a SQL statement ...
SELECT ReviewerName FROM ProductReview WHERE Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating DESC LIMIT 1 );
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
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;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
SELECT COUNT(T1.ProductID) FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MakeFlag = 0 AND T1.Rating != 5;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
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;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 USING (ProductID) WHERE T2.FinishedGoodsFlag = 1 AND T2.MakeFlag = 1 GROUP BY T2.Name ORDER BY COUNT(T1.COMMENTS) > 10;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
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;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
SELECT T1.ReviewerName FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Class = 'M' AND T2.Style = 'W' AND T1.Rating = 5;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
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;
[INST] Here is a database schema: ProductReview : ProductReviewID [ INTEGER ] primary_key ProductID [ INTEGER ] ProductReview.ProductID = Product.ProductID ReviewerName [ TEXT ] ReviewDate [ DATETIME ] EmailAddress [ TEXT ] Rating [ INTEGER ] Comments [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] p...
SELECT T1.EmailAddress FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Class = 'H';
[INST] Here is a database schema: ProductListPriceHistory : ProductID [ INTEGER ] ProductListPriceHistory.ProductID = Product.ProductID StartDate [ DATE ] EndDate [ DATE ] ListPrice [ REAL ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] primary_key Name [ TEXT ] ProductNumber [ TEXT ] MakeFlag [ INTEGER ] F...
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;
[INST] Here is a database schema: ProductDescription : ProductDescriptionID [ INTEGER ] primary_key Description [ TEXT ] rowguid [ TEXT ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] primary_key Name [ TEXT ] ProductNumber [ TEXT ] MakeFlag [ INTEGER ] FinishedGoodsFlag [ INTEGER ] Color [ TEXT ] SafetySto...
SELECT T1.Description FROM ProductDescription AS T1 INNER JOIN Product AS T2 WHERE T2.Name = 'Headset Ball Bearings' AND T1.productDescriptionID = T2.ProductID;
[INST] Here is a database schema: ProductVendor : ProductID [ INTEGER ] ProductVendor.ProductID = Product.ProductID BusinessEntityID [ INTEGER ] ProductVendor.BusinessEntityID = Vendor.BusinessEntityID AverageLeadTime [ INTEGER ] StandardPrice [ REAL ] LastReceiptCost [ REAL ] LastReceiptDate [ DATETIME ] MinOrderQty [...
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;
[INST] Here is a database schema: ProductVendor : ProductID [ INTEGER ] ProductVendor.ProductID = Product.ProductID BusinessEntityID [ INTEGER ] ProductVendor.BusinessEntityID = Vendor.BusinessEntityID AverageLeadTime [ INTEGER ] StandardPrice [ REAL ] LastReceiptCost [ REAL ] LastReceiptDate [ DATETIME ] MinOrderQty [...
SELECT T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5' GROUP BY T1.StandardPrice ORDER BY COUNT(T1.StandardPrice) DESC LIMIT 1;
[INST] Here is a database schema: Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.BusinessEntityID = BusinessEntity.BusinessEntityID AccountNumber [ TEXT ] Name [ TEXT ] CreditRating [ INTEGER ] PreferredVendorStatus [ INTEGER ] ActiveFlag [ INTEGER ] PurchasingWebServiceURL [ TEXT ] ModifiedDate [ DATETIME ] ...
SELECT COUNT(DISTINCT T3.Name) FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Name = 'Hex Nut 5' AND T3.CreditRating = 1 AND 3;
[INST] Here is a database schema: Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.BusinessEntityID = BusinessEntity.BusinessEntityID AccountNumber [ TEXT ] Name [ TEXT ] CreditRating [ INTEGER ] PreferredVendorStatus [ INTEGER ] ActiveFlag [ INTEGER ] PurchasingWebServiceURL [ TEXT ] ModifiedDate [ DATETIME ] ...
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';
[INST] Here is a database schema: Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.BusinessEntityID = BusinessEntity.BusinessEntityID AccountNumber [ TEXT ] Name [ TEXT ] CreditRating [ INTEGER ] PreferredVendorStatus [ INTEGER ] ActiveFlag [ INTEGER ] PurchasingWebServiceURL [ TEXT ] ModifiedDate [ DATETIME ] ...
SELECT T3.Name FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Name = 'Hex Nut 5' ORDER BY T1.StandardPrice LIMIT 1;
[INST] Here is a database schema: Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.BusinessEntityID = BusinessEntity.BusinessEntityID AccountNumber [ TEXT ] Name [ TEXT ] CreditRating [ INTEGER ] PreferredVendorStatus [ INTEGER ] ActiveFlag [ INTEGER ] PurchasingWebServiceURL [ TEXT ] ModifiedDate [ DATETIME ] ...
SELECT COUNT(T2.Name) FROM ProductVendor AS T1 INNER JOIN Product AS T2 USING (ProductID) INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.PreferredVendorStatus = 1 AND T2.Class = 'M';
[INST] Here is a database schema: ProductListPriceHistory : ProductID [ INTEGER ] ProductListPriceHistory.ProductID = Product.ProductID StartDate [ DATE ] EndDate [ DATE ] ListPrice [ REAL ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] primary_key Name [ TEXT ] ProductNumber [ TEXT ] MakeFlag [ INTEGER ] F...
SELECT T2.ListPrice FROM Product AS T1 INNER JOIN ProductListPriceHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'LL Fork';
[INST] Here is a database schema: Vendor : BusinessEntityID [ INTEGER ] primary_key Vendor.BusinessEntityID = BusinessEntity.BusinessEntityID AccountNumber [ TEXT ] Name [ TEXT ] CreditRating [ INTEGER ] PreferredVendorStatus [ INTEGER ] ActiveFlag [ INTEGER ] PurchasingWebServiceURL [ TEXT ] ModifiedDate [ DATETIME ] ...
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;