Analytic Function preserve the partitioning
Analytic Functions are great. They are SQL standard so all databases implement them. Anyway I'm working on Oracle, so I'm using them on 19c (and previous releases).
Sometime, the behavior is not what you expect. This is what happened to me during some calculation of sequential values grouped separately.
Suppose for example that a car is in the Park A for 3 days. Then it move in the Park B for 5 days and in the Park A for other 3 days. Totally, the car is in the Park for 11 days (3A + 5B + 3A). But what about to use ROW_NUMBER function? It will return 6 days in Park A (3 + 3) and 5 in Park B.
ROW_NUMBER, preserve the "Park" partition, that is, the Analytic Functions group together all rows inside the "partition" clause.
In order to address this behavior and obtain a result set as 3A + 5B + 3A days instead 6A + 5B, I wrote a post (I divided it in 6 little parts) on my Blog. You can read it, here (the link point to the part 1).