Why is it that in SQL Server I can\'t do this:
select sum(count(id)) as \'count\'
from table
But I can do
select sum(x.
Microsoft SQL Server doesn’t support it.
You can get around this problem by using a Derived
table:
select sum(x.count)
from
(
select count(id) as 'count'
from table
) x
On the other hand using the below code will give you an error message.
select sum(count(id)) as 'count'
from table
Cannot perform an aggregate function on an expression containing an aggregate or a subquery