goollan
goollan

Reputation: 785

What's the point of the ALL modifier in window functions?

I read the definition of the all modifier ALL as

ALL is an optional keyword. When you will include ALL it will count all values including duplicate ones. DISTINCT is not supported in window functions

My understanding is that it automatically would count all values anyway.

If that's the case, then why create an ALL keyword at all?

Upvotes: 0

Views: 37

Answers (2)

Lukasz Szozda
Lukasz Szozda

Reputation: 175914

"If that's the case, then why create an ALL keyword at all?"

There is a great Python rule called: EIBTI

Explicit is better than implicit.


For the same reason you have constructs like:

CREATE TABLE tab(
  col INT NULL   -- there is no need specify NULL because column is nullable by design
);

ALTER TABLE t ADD CONSTRAINT("t_FK") FOREIGN KEY ("c_ID")
REFERENCES "t2" ("c_ID") ENABLE;   -- constraint is enabled by default

Every "default" behavior does not need keyword, but if we could state something explicitly why shouldn't we.

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1270331

ALL is pretty much never used in practice. The point is to balance the syntax, so the default has an explicit keyword.

Similarly, some databases support UNION DISTINCT (which is equivalent to UNION) as a contrast to UNION ALL, to make it clear that there is an additional function on UNION -- the removal of duplicates.

Upvotes: 2

Related Questions