窗口函数sum() over()不支持和group by同时使用?
以下语句报错
select name, sum(payment) as payments, sum(payment) over() as total
from table1
group by name
因为窗口函数是对group by的结果进行计算,而group by 中不包含payment
只能
select name, payments, sum(payments) over() as total
from
(
select name, sum(payment) as payments
from table1
group by name
) t1
或者
select name, sum(payment) as payments, sum(sum(payment)) over() as total
from table1
group by name