Why can't I perform an aggregate function on an expression containing an aggregate but I can do so by creating a new select statement around it?

后端 未结 7 711
囚心锁ツ
囚心锁ツ 2020-12-09 02:48

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.         


        
7条回答
  •  轮回少年
    2020-12-09 03:36

    I think you can write the sql query, which produces 'count' of rows for the required output. Functions do not take aggregated functions like 'sum' or aggregated subquery. My problem was resolved by using a simple sql query to get the count out....

提交回复
热议问题