Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试选择几个不同的总和,其中之一是OVER (Partition by column_also_in_select_plan).
OVER (Partition by column_also_in_select_plan)
但是,我似乎永远无法GROUP BY正确声明。
GROUP BY
例子:
Select 1, 2, 3, sum(4) over (partition by 3), sum(case when 6 = etc...) FROM table Where filters GROUP BY ?
感谢您的任何提示:)
同时进行聚合和使用窗口函数并没有多大意义,所以我并不奇怪你会感到困惑。在上面的示例中,您可能希望将窗口移动到外部查询,即:
select 1, 2, 3, sum(sum4) over(partition by 3), ... from ( select 1, 2, 3, sum(4) as sum4 from table where filters group by 1, 2, 3 ) x