-
Notifications
You must be signed in to change notification settings - Fork 3
sql window function
ghdrako edited this page Apr 16, 2024
·
3 revisions
window functions
SELECT {columns},
{window_func} OVER (PARTITION BY {partition_key} ORDER BY {order_key})
FROM table1;
Window functions create aggregates without flattening the data into a single row. However, they replicate it for all the rows to which the grouping functions refer.
select category, count(*) over (partition by category) from posts order by category;
Test