Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
In the following TSQL from SQL 2005 I want to get the sum of the I get the followingCannot perform an aggregate function on an expression containing an aggregate or a subquery.I believe it's << Sum(SUM(B.QTY) * BF.BOM_QTY)>> this that is causing the error. How can I pull that value into an outer query so I can sum it?=============================================SELECT BF.PART ,Sum(SUM(B.QTY) * BF.BOM_QTY) AS CONSUMED FROM BUILDS BINNER JOIN V_BACK_FLUSH_BOM BFON BF.ASSEMBLYID = B.ASSEMBLY_IDwhere part = '37220004'GROUP BY BF.PART,BF.BOM_QTY=============================================
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-01-12 : 12:34:42
MAY BE THIS
select BF.PART,sum(CONSUMED)from(SELECT BF.PART,SUM(B.QTY) * BF.BOM_QTY AS CONSUMEDFROM BUILDS BINNER JOIN V_BACK_FLUSH_BOM BFON BF.ASSEMBLYID = B.ASSEMBLY_IDwhere part = '37220004'GROUP BY BF.PART,BF.BOM_QTY)Tgroup by BF.PART