sql window function - ghdrako/doc_snipets GitHub Wiki
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;