SQL Server Performance

Using Agg Function within subquery

Discussion in 'SQL Server 2008 General Developer Questions' started by alisag, Jan 31, 2010.

  1. alisag New Member

    I wrote the following code. But i m getting error that MIN is not a recognized built in function.SELECT [Prod_ Order No_],[Location Code],[Item No_],Sum([Remaining Quantity]) AS [Open Qty],Table1.Inventory,Table1.[Percent Complete]FROM [CompanyName$Prod_ Order Component] AS POCLEFT OUTER JOIN(SELECT [Item No_],Sum(Quantity) As Inventory,MIN(CASE WHEN ISNULL(Inventory,0)= 0 Then 0 else case when (Inventory/POC.[Open Quantity]) > 1 then 1 else (Inventory/POC.[Open Quantity]) END END) FROM [CompanyName$Item Ledger Entry] Group By [Item No_]) AS Table1 ON POC.[Item No_] = Table1.[Item No_]GROUP BY [Prod_ Order No_],[Location Code],[Item No_]HAVING (Sum([Remaining Quantity]) > 0)
  2. preethi Member

    Please, Please Please format the code so that people can read the query without straining.
    I believe you haven;t specified a name for the calculated value which starts with MIN.

Share This Page