SQL Partition

Partition #

Partitioning in SQL breaks the data into partitions, and performs aggregative methods over the individual partitions.

PARTITION BY is a subclause of the OVER clause.

SELECT <aggregation method>(<field>) OVER(
    PARTITION BY <field>
) <new output field name>
FROM <table>;

Difference from GROUP BY #

GROUP BY reduces the number of rows returned per group.

PARTITION BY does not reduce the number of rows returned per partition.