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.
いくつかの異なる合計を選択しようとしていますが、そのうちの 1 つが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