input
stringlengths
122
2.7k
output
stringlengths
24
805
[INST] Here is a database schema: ProductCostHistory : ProductID [ INTEGER ] ProductCostHistory.ProductID = Product.ProductID StartDate [ DATE ] EndDate [ DATE ] StandardCost [ REAL ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] primary_key Name [ TEXT ] ProductNumber [ TEXT ] MakeFlag [ INTEGER ] Finished...
SELECT T1.Name, T2.StartDate FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T2.EndDate IS NULL;
[INST] Here is a database schema: ProductCostHistory : ProductID [ INTEGER ] ProductCostHistory.ProductID = Product.ProductID StartDate [ DATE ] EndDate [ DATE ] StandardCost [ REAL ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] primary_key Name [ TEXT ] ProductNumber [ TEXT ] MakeFlag [ INTEGER ] Finished...
SELECT T1.Name FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.StandardCost - T2.StandardCost > 80 GROUP BY T1.Name;
[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 T1.Name, T2.Quantity FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ShoppingCartID = 14951;
[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 T1.Name FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 5;
[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 DISTINCT T1.Name FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Class = 'L' AND T2.TransactionType = 'P' ORDER BY T1.Name;
[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 DISTINCT T1.Name, T1.ListPrice FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 10000;
[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 T1.Name FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Class = 'H' ORDER BY T2.Quantity ASC 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(T2.TransactionID) FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductLine = 'M';
[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 SUM((T1.ListPrice - T1.StandardCost) * T2.Quantity) FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ShoppingCartID = 20621;
[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, ListPrice FROM Product WHERE Class = 'H';
[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 ProductLine FROM Product WHERE FinishedGoodsFlag = 1 GROUP BY ProductLine ORDER BY COUNT(FinishedGoodsFlag) 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 ProductID, Rating, Comments FROM ProductReview WHERE ReviewerName LIKE 'J%';
[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.Name, T1.ProductLine, T2.Rating, T1.ListPrice FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID ORDER BY T2.Rating ASC LIMIT 1;
[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 DISTINCT Name FROM Product WHERE ListPrice - StandardCost > 100;
[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.Name, T2.ReviewerName, T2.Rating, T2.Comments FROM Product AS T1 INNER JOIN ProductReview AS T2 USING (productID) WHERE T1.ProductLine = 'R';
[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), AVG(T2.Rating) FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'HL Mountain Pedal';
[INST] Here is a database schema: PurchaseOrderDetail : PurchaseOrderID [ INTEGER ] PurchaseOrderDetail.PurchaseOrderID = PurchaseOrderHeader.PurchaseOrderID PurchaseOrderDetailID [ INTEGER ] primary_key DueDate [ DATETIME ] OrderQty [ INTEGER ] ProductID [ INTEGER ] PurchaseOrderDetail.ProductID = Product.ProductID Un...
SELECT T1.Name FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.RejectedQty = T2.ReceivedQty AND T2.RejectedQty <> 0;
[INST] Here is a database schema: PurchaseOrderDetail : PurchaseOrderID [ INTEGER ] PurchaseOrderDetail.PurchaseOrderID = PurchaseOrderHeader.PurchaseOrderID PurchaseOrderDetailID [ INTEGER ] primary_key DueDate [ DATETIME ] OrderQty [ INTEGER ] ProductID [ INTEGER ] PurchaseOrderDetail.ProductID = Product.ProductID Un...
SELECT T1.Name, T2.UnitPrice FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.RejectedQty = 0 ORDER BY T2.LineTotal DESC LIMIT 1;
[INST] Here is a database schema: PurchaseOrderDetail : PurchaseOrderID [ INTEGER ] PurchaseOrderDetail.PurchaseOrderID = PurchaseOrderHeader.PurchaseOrderID PurchaseOrderDetailID [ INTEGER ] primary_key DueDate [ DATETIME ] OrderQty [ INTEGER ] ProductID [ INTEGER ] PurchaseOrderDetail.ProductID = Product.ProductID Un...
SELECT T1.Name, T1.ProductLine FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderQty > 4999;
[INST] Here is a database schema: PurchaseOrderDetail : PurchaseOrderID [ INTEGER ] PurchaseOrderDetail.PurchaseOrderID = PurchaseOrderHeader.PurchaseOrderID PurchaseOrderDetailID [ INTEGER ] primary_key DueDate [ DATETIME ] OrderQty [ INTEGER ] ProductID [ INTEGER ] PurchaseOrderDetail.ProductID = Product.ProductID Un...
SELECT SUM(T2.OrderQty) FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductLine = 'T';
[INST] Here is a database schema: PurchaseOrderDetail : PurchaseOrderID [ INTEGER ] PurchaseOrderDetail.PurchaseOrderID = PurchaseOrderHeader.PurchaseOrderID PurchaseOrderDetailID [ INTEGER ] primary_key DueDate [ DATETIME ] OrderQty [ INTEGER ] ProductID [ INTEGER ] PurchaseOrderDetail.ProductID = Product.ProductID Un...
SELECT T1.Name, T2.LineTotal FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE Class = 'L' ORDER BY OrderQty * UnitPrice 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.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID ORDER BY T2.LastReceiptCost - T2.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 DISTINCT T1.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MinOrderQty = 100 ORDER BY T1.Name DESC;
[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.Name, T1.ListPrice - T1.StandardCost FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID ORDER BY T2.Rating DESC 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 SUM((T1.ListPrice - T1.StandardCost) * T2.Quantity) FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductID = 827;
[INST] Here is a database schema: CurrencyRate : CurrencyRateID [ INTEGER ] primary_key CurrencyRateDate [ DATETIME ] FromCurrencyCode [ TEXT ] ToCurrencyCode [ TEXT ] AverageRate [ REAL ] EndOfDayRate [ REAL ] ModifiedDate [ DATETIME ] Please write me a SQL statement that answers the following question: Which currenc...
SELECT FromCurrencyCode, ToCurrencyCode FROM CurrencyRate ORDER BY AverageRate DESC LIMIT 1;
[INST] Here is a database schema: PurchaseOrderDetail : PurchaseOrderID [ INTEGER ] PurchaseOrderDetail.PurchaseOrderID = PurchaseOrderHeader.PurchaseOrderID PurchaseOrderDetailID [ INTEGER ] primary_key DueDate [ DATETIME ] OrderQty [ INTEGER ] ProductID [ INTEGER ] PurchaseOrderDetail.ProductID = Product.ProductID Un...
SELECT OrderQty FROM PurchaseOrderDetail ORDER BY UnitPrice DESC LIMIT 1;
[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 Name FROM SalesTerritory WHERE CountryRegionCode = 'US' AND (Name = 'Northwest' OR Name = 'Southeast') ORDER BY SalesLastYear 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.FirstName, T1.MiddleName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Document AS T3 ON T3.Owner = T2.BusinessEntityID WHERE T2.JobTitle = 'Document Control Manager' AND T3.DocumentLevel = 1 AND T3.Status = 2 GROUP BY T1.FirstName, T1.MiddleN...
[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 T1.CustomerID FROM SalesOrderHeader AS T1 INNER JOIN SalesPerson AS T2 ON T1.SalesPersonID = T2.BusinessEntityID ORDER BY T1.SubTotal DESC LIMIT 1;
[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 ] SalesOrderDetail : SalesOrderID [...
SELECT T2.UnitPrice * T2.OrderQty FROM SpecialOffer AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID WHERE T1.Description = 'Volume Discount 11 to 14' AND T1.SpecialOfferID = 2 AND T2.ProductID = 716 AND T2.SalesOrderID = 46625;
[INST] Here is a database schema: BillOfMaterials : BillOfMaterialsID [ INTEGER ] primary_key ProductAssemblyID [ INTEGER ] ComponentID [ INTEGER ] StartDate [ DATETIME ] EndDate [ DATETIME ] UnitMeasureCode [ TEXT ] BOMLevel [ INTEGER ] PerAssemblyQty [ REAL ] ModifiedDate [ DATETIME ] Product : ProductID [ INTEGER ] ...
SELECT COUNT(T1.ProductID) FROM Product AS T1 INNER JOIN BillOfMaterials AS T2 ON T1.ProductID = T2.ProductAssemblyID WHERE T1.MakeFlag = 1 AND T1.DaysToManufacture = 1 AND T2.BOMLevel = 4 AND T1.ReorderPoint <= 600;
[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.Bonus FROM SalesTerritory AS T1 INNER JOIN SalesPerson AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T1.CountryRegionCode = 'CA' ORDER BY T2.SalesQuota 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 WHERE T1.Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating ASC LIMIT 1 );
[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 COUNT(T2.BusinessEntityID) FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID WHERE T2.StartDate >= '2009-01-01' AND T2.StartDate < '2010-01-01' AND T1.Name = 'Production';
[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.FirstName, T3.MiddleName, T3.LastName, T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'S' AND T1.Gender = 'F' 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, T1.HireDate FROM Employee AS T1 INNER JOIN Person AS T2 USING (BusinessEntityID) WHERE T1.JobTitle = 'Vice President of Engineering';
[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.CurrentFlag = 1 AND T2.Rate <= 30;
[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 T1.Name FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID ORDER BY T2.StartDate 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, T1.Gender FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'SP';
[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 ORDER BY T1.SickLeaveHours ASC 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 T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.Rate ASC LIMIT 1;
[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 COUNT(T2.BusinessEntityID) FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 USING (DepartmentID) WHERE T1.Name = 'Finance';
[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 ( SELECT ListPrice - StandardCost FROM Product WHERE ListPrice != 0 ORDER BY ListPrice DESC LIMIT 1 ) , ( SELECT ListPrice - StandardCost FROM Product WHERE ListPrice != 0 ORDER BY ListPrice 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 T2.Name, T1.LastReceiptCost - T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CreditRating = 3;
[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 ] Please write me a SQL statement that answers the following question...
SELECT COUNT(*) FROM Address WHERE AddressLine2 <> '';
[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 ] Please write me a SQL statement that answers the following question...
SELECT PostalCode FROM Address ORDER BY ModifiedDate DESC LIMIT 1;
[INST] Here is a database schema: BillOfMaterials : BillOfMaterialsID [ INTEGER ] primary_key ProductAssemblyID [ INTEGER ] ComponentID [ INTEGER ] StartDate [ DATETIME ] EndDate [ DATETIME ] UnitMeasureCode [ TEXT ] BOMLevel [ INTEGER ] PerAssemblyQty [ REAL ] ModifiedDate [ DATETIME ] Please write me a SQL statement...
SELECT JULIANDAY(EndDate) - JULIANDAY(StartDate) FROM BillOfMaterials ORDER BY JULIANDAY(EndDate) - JULIANDAY(StartDate) DESC LIMIT 1;
[INST] Here is a database schema: BillOfMaterials : BillOfMaterialsID [ INTEGER ] primary_key ProductAssemblyID [ INTEGER ] ComponentID [ INTEGER ] StartDate [ DATETIME ] EndDate [ DATETIME ] UnitMeasureCode [ TEXT ] BOMLevel [ INTEGER ] PerAssemblyQty [ REAL ] ModifiedDate [ DATETIME ] Please write me a SQL statement...
SELECT COUNT(BillOfMaterialsID) FROM BillOfMaterials WHERE EndDate IS NULL;
[INST] Here is a database schema: BillOfMaterials : BillOfMaterialsID [ INTEGER ] primary_key ProductAssemblyID [ INTEGER ] ComponentID [ INTEGER ] StartDate [ DATETIME ] EndDate [ DATETIME ] UnitMeasureCode [ TEXT ] BOMLevel [ INTEGER ] PerAssemblyQty [ REAL ] ModifiedDate [ DATETIME ] Please write me a SQL statement...
SELECT UnitMeasureCode FROM BillOfMaterials ORDER BY PerAssemblyQty DESC LIMIT 1;
[INST] Here is a database schema: Document : DocumentNode [ TEXT ] primary_key DocumentLevel [ INTEGER ] Title [ TEXT ] Owner [ INTEGER ] FolderFlag [ INTEGER ] FileName [ TEXT ] FileExtension [ TEXT ] Revision [ TEXT ] ChangeNumber [ INTEGER ] Status [ INTEGER ] DocumentSummary [ TEXT ] Document [ BLOB ] rowguid [ TEX...
SELECT COUNT(DocumentNode) FROM Document WHERE DocumentSummary IS NULL;
[INST] Here is a database schema: Document : DocumentNode [ TEXT ] primary_key DocumentLevel [ INTEGER ] Title [ TEXT ] Owner [ INTEGER ] FolderFlag [ INTEGER ] FileName [ TEXT ] FileExtension [ TEXT ] Revision [ TEXT ] ChangeNumber [ INTEGER ] Status [ INTEGER ] DocumentSummary [ TEXT ] Document [ BLOB ] rowguid [ TEX...
SELECT Title FROM Document WHERE Status = 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 DISTINCT T2.BusinessEntityID, T2.JobTitle FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T1.Status = 2;
[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.PayFrequency FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.BirthDate ASC 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 COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.MaritalStatus = 'M' AND T1.PayFrequency = ( SELECT PayFrequency FROM EmployeePayHistory ORDER BY PayFrequency DESC 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 T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.HireDate DESC 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 SUM(CASE WHEN T2.Gender = 'M' THEN 1 ELSE 0 END) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Rate > 40;
[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.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.SalariedFlag = 1 ORDER BY T1.Rate DESC 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.VacationHours FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.BusinessEntityID = ( SELECT BusinessEntityID FROM EmployeePayHistory ORDER BY Rate DESC 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 T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.VacationHours DESC 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 COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.SickLeaveHours > 10 AND T1.Rate > 35;
[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 EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.Gender = 'M' AND T1.PayFrequency = 2;
[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(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'M' AND T2.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 T2.PersonType FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.BirthDate ASC 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.NameStyle FROM EmployeePayHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Rate IS NOT NULL ORDER BY T1.Rate ASC 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(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.NameStyle = 0 AND T1.MaritalStatus = 'M';
[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(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1 AND T1.SickLeaveHours > 10;
[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.BusinessEntityID FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1 AND T1.VacationHours > 20;
[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.AdditionalContactInfo FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE PersonType = 'SP' ORDER BY T1.BirthDate ASC 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 FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.NameStyle = 0 AND T1.Gender = 'M';
[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(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.CurrentFlag = 1 AND T2.Title = 'Mr.';
[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.Demographics FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeePayHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'M' ORDER BY T3.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.Suffix FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'SP' ORDER BY T1.SickLeaveHours 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(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeePayHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'M' AND T2.NameStyle = 1 AND T3.Rate = ( SELECT Rate FROM EmployeePayHistory ORDER BY Rate ...
[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(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.CurrentFlag = 1 AND 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 T2.CreditCardID FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.PersonType = 'SC';
[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(T1.VacationHours) AS REAL) / COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'M' AND T2.PersonType = 'EM';
[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 MAX(T1.Rate) - SUM(T1.Rate) / COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T2.EmailPromotion = 2 AND T3.MaritalStatus = 'M';
[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(COUNT(IIF(T1.PersonType = 'SC', T1.PersonType, NULL)) AS REAL) / COUNT(T1.PersonType) FROM Person AS T1 INNER JOIN Employee AS T2 WHERE T1.PersonType = 'SC' AND T1.NameStyle = 0 AND T2.MaritalStatus = 'M';
[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 CAST(SUM(CASE WHEN T2.VacationHours > 20 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.SickLeaveHours > 10;
[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 SUM(LastReceiptCost) / COUNT(ProductID) FROM ProductVendor WHERE AverageLeadTime = 60;
[INST] Here is a database schema: TransactionHistoryArchive : TransactionID [ INTEGER ] primary_key ProductID [ INTEGER ] ReferenceOrderID [ INTEGER ] ReferenceOrderLineID [ INTEGER ] TransactionDate [ DATETIME ] TransactionType [ TEXT ] Quantity [ INTEGER ] ActualCost [ REAL ] ModifiedDate [ DATETIME ] Please write m...
SELECT CAST(SUM(ActualCost) AS REAL) / COUNT(TransactionID) FROM TransactionHistoryArchive WHERE TransactionType = 'P' AND TransactionDate >= '2012-01-01' AND TransactionDate < '2012-07-01';
[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 CAST(SUM(CASE WHEN MaritalStatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(BusinessEntityID) FROM Employee WHERE SUBSTR(HireDate, 1, 4) = '2009' AND Gender = 'M';
[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 EmailPromotion = 2 THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN PersonType = 'SC' THEN 1 ELSE 0 END) FROM Person WHERE FirstName = 'Mary';
[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 DISTINCT ProductID FROM ProductVendor WHERE StandardPrice - LastReceiptCost < 0;
[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) / COUNT(TotalDue) FROM PurchaseOrderHeader WHERE Status = 2;
[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 CAST(SUM(CASE WHEN OrderQty < 3 AND UnitPriceDiscount = 0.2 THEN 1 ELSE 0 END) AS REAL) / COUNT(SalesOrderID) FROM SalesOrderDetail;
[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 WHERE SalesYTD > SalesLastYear + SalesLastyear * 0.6 AND Bonus > 3000;
[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 SUM(CASE WHEN T2.Name = 'Home' THEN 1 ELSE 0 END) , SUM(CASE WHEN T2.Name = 'Shipping' THEN 1 ELSE 0 END) FROM BusinessEntityAddress AS T1 INNER JOIN AddressType AS T2 ON T1.AddressTypeID = T2.AddressTypeID;
[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 T2.CustomerID FROM SalesOrderDetail AS T1 INNER JOIN Customer AS T2 WHERE T1.UnitPrice = 35 AND T1.OrderQty = 32;
[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.CardType = 'ColonialVoice' AND T1.ExpMonth = 3 AND T1.ExpYear = 2005;
[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.CreditRating FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.StandardPrice = 18.9900 AND T1.AverageLeadTime = 16 AND STRFTIME('%Y-%m-%d', T1.LastReceiptDate) = '2011-08-27';
[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 COUNT(ProductID) FROM Product WHERE Name LIKE '%accessories %' OR Name LIKE '%components%';
[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.JobTitle FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.DepartmentID = 12 ORDER BY T2.StartDate DESC LIMIT 1;
[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.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaritalStatus = 'S' AND T1.Gender = 'M' AND T1.JobTitle LIKE 'Production Supervisor%';
[INST] Here is a database schema: ProductInventory : ProductID [ INTEGER ] ProductInventory.ProductID = Product.ProductID LocationID [ INTEGER ] ProductInventory.LocationID = Location.LocationID Shelf [ TEXT ] Bin [ INTEGER ] Quantity [ INTEGER ] rowguid [ TEXT ] ModifiedDate [ DATETIME ] Location : LocationID [ INTEGE...
SELECT COUNT(T1.LocationID) FROM Location AS T1 INNER JOIN ProductInventory AS T2 USING (LocationID) WHERE T1.Name = 'Subassembly';
[INST] Here is a database schema: ScrapReason : ScrapReasonID [ INTEGER ] primary_key Name [ TEXT ] ModifiedDate [ DATETIME ] WorkOrder : WorkOrderID [ INTEGER ] primary_key ProductID [ INTEGER ] WorkOrder.ProductID = Product.ProductID OrderQty [ INTEGER ] StockedQty [ INTEGER ] ScrappedQty [ INTEGER ] StartDate [ DATE...
SELECT SUM(T2.ScrappedQty) FROM ScrapReason AS T1 INNER JOIN WorkOrder AS T2 ON T1.ScrapReasonID = T2.ScrapReasonID WHERE T1.Name = 'Trim length too long';
[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(T2.OrderQty) FROM PurchaseOrderHeader AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID WHERE T1.Status = 1;
[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 COUNT(DISTINCT T1.ProductID) FROM SalesOrderDetail AS T1 INNER JOIN SpecialOfferProduct AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID INNER JOIN SpecialOffer AS T3 ON T2.SpecialOfferID = T3.SpecialOfferID WHERE T1.OrderQty > 2 AND T1.UnitPriceDiscount = 0;
[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 DISTINCT T2.TransactionType FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Size = 62 AND T1.Color = 'Yellow' AND T1.SafetyStockLevel = 500;