The Netezza documentation for Window Partitioning states you can use window partition syntax to name one or more columns. I would appreciate it if someone would please provide me an example of this?
I don't really understand the documentation below:
<window partition clause> ::= partition by <column reference list>
<column reference list> ::= <value expression>
The good thing is that you're not restricted to just Netezza in your documentation for window partitions. You can use the underlying PostgreSQL documentation, or SQL Server! There will always be subtle differences, but they're mostly the same.
That said, the window partition clause mentioned in the documentation refers to the portion of code you must place to declare the aggregate function a windowed aggregate. Normally, you'd write something like this.
select id, sum(col) from tbl group by id;
To declare this a windowed aggregate, you need to put in the window partition clause, which (almost) always begins with partition by
.
select id, sum(col) over (partition by id) from tbl;
The column reference list you cite is usually just of columns the way you'd list them in a select
. Similar to a select
, though, you can always make new columns here. That's what they mean by a value expression.
select id, sum(col) over (partition by case when id > 10 then 1 else 0 end) from tbl;