题解 | 计算每日累计利润
计算每日累计利润
https://www.nowcoder.com/practice/c9b7a2f73eb54a3da4a81f15fd8a3665
解析:经典窗口函数 在 SQL 中,聚合类窗口函数(Aggregate Window Functions) 是窗口函数的一种特殊类型,它允许在保留原始行数据的同时, 基于定义的“窗口”(一组相关行)执行聚合计算。与普通聚合函数(如 `SUM`、`AVG`)不同, 聚合类窗口函数不会将多行合并为单行结果,而是为每一行返回其所属窗口的聚合值。 select profit_id,profit_date,profit, sum(profit) over(order by profit_date) cumulative_profit from daily_profits order by profit_date;

