New answers tagged window-functions
3
votes
Accepted
Understanding the Impact of ORDER BY in Window Functions on other Partitions in PostgreSQL
Think of your data as a pile of clothes, where the odd column stores the id of a type of clothing (shirt, pants, socks, etc). The PARTITION clause on odd is the equivalent of organizing the clothes ...
2
votes
Understanding the Impact of ORDER BY in Window Functions on other Partitions in PostgreSQL
Without the ORDER BY, the expression is underdetermined. There are multiple possible answers, of which it returns the most convenient to compute. Once one expression gains an ORDER BY, then it ...
0
votes
Window functions and distinct
You can use a combination of window functions and normal group by on the same partitioning, rather than using distinct. This means the optimizer can rely on the required sort not changing.
You can use ...
1
vote
Accepted
Window functions and distinct
Instead of using window functions, which don't reduce the number of result rows, and then DISTINCT, which does, it would be better to use aggregate functions that do both in a single step.
We need ...
Top 50 recent answers are included
Related Tags
window-functions × 332postgresql × 178
sql-server × 86
aggregate × 44
gaps-and-islands × 34
group-by × 21
t-sql × 20
mysql × 19
performance × 13
query-performance × 13
sql-server-2012 × 12
join × 12
oracle × 11
rank × 11
count × 10
cte × 10
greatest-n-per-group × 10
running-totals × 10
sql-server-2008-r2 × 9
sql-server-2014 × 9
query × 8
postgresql-performance × 8
sql-server-2016 × 7
update × 7
sql-server-2008 × 6