locked
Cannot perform Data Base RRS feed

  • Question

  • User1788249541 posted

    Dear all,

      I Got the below error, while exwcuting the (select sum(sum(lmeter)*FabricWidth) from FabricExportPackingAbstractReporttbl
    group by lmeter,FabricWidth) query

    ERROR : Msg 130, Level 15, State 1, Line 2
    Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

    Kindly help to solve

    Thanks in Advance!!..

    Jagadeesh

    Monday, November 14, 2016 5:45 AM

Answers

  • User753101303 posted

    Hi,

    This is because you are doing a sum and then again a sum in the same grouping context which doesn't make sense. Also this is a subquery maybe in a field list ?

    Could it be that you just want :

    (select sum(meter*FabricWidth) from FabricExportPackingAbstractReporttbl)

    ie the total sum for all those those rows? Else we'll likely need some more context to better understand your intent.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 14, 2016 12:11 PM
  • User364663285 posted

    Try

    select sum(lmeter*FabricWidth) from FabricExportPackingAbstractReporttbl

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 15, 2016 6:02 AM
  • User-2057865890 posted

    Hi Vjagades,

    select sum(t.total) from
    (
       select sum(lmeter)*FabricWidth as total from FabricExportPackingAbstractReporttbl
       group by lmeter,FabricWidth
    ) as t

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 15, 2016 9:09 AM

All replies

  • User753101303 posted

    Hi,

    This is because you are doing a sum and then again a sum in the same grouping context which doesn't make sense. Also this is a subquery maybe in a field list ?

    Could it be that you just want :

    (select sum(meter*FabricWidth) from FabricExportPackingAbstractReporttbl)

    ie the total sum for all those those rows? Else we'll likely need some more context to better understand your intent.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 14, 2016 12:11 PM
  • User364663285 posted

    Try

    select sum(lmeter*FabricWidth) from FabricExportPackingAbstractReporttbl

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 15, 2016 6:02 AM
  • User-2057865890 posted

    Hi Vjagades,

    select sum(t.total) from
    (
       select sum(lmeter)*FabricWidth as total from FabricExportPackingAbstractReporttbl
       group by lmeter,FabricWidth
    ) as t

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 15, 2016 9:09 AM