Home Forums SQL Server 2008 SQL Server 2008 - General Cannot Perform an Aggregate function on an expression containing an aggregate or a subquery RE: Cannot Perform an Aggregate function on an expression containing an aggregate or a subquery

  • Try this

    WITH Capacities AS (

    select en.NAME as ClusterName, ROUND(CAST(CPU_CORE_COUNT as FLOAT)*CPU_Hz*count(cast(hs.HOSTID as BIGINT))/800000000,0) as Hub_Capacity

    from VPXV_HOSTS as hs WITH (NOLOCK,NOWAIT)

    full join VPXV_ENTITY as en WITH (NOLOCK,NOWAIT) on hs.FARMID = en.id

    where en.TYPE_ID = 3

    group by en.Name, hs.CPU_CORE_COUNT, hs.CPU_Hz

    )

    SELECT SUM(Hub_Capacity) AS TotalCapacity

    Pretty sure John just forgot to remove the sum in the cte.