Analytic Function preserve the partitioning

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).





要查看或添加评论,请登录

Andrea Salzano的更多文章

  • 2 physical concepts in Oracle database

    2 physical concepts in Oracle database

    It could be strange, but yes, there are 2 concepts that came from physic that you can apply to your oracle database…

  • How to rescue data after a mistake

    How to rescue data after a mistake

    Oracle give you the opportunity to recover data also if you delete them or dropped the table. Here 2 simple example…

  • Using SQL like Excel - First example

    Using SQL like Excel - First example

    In my previous post, I have shown the relation between SQL MODEL clause and an Excel spreadsheet. In this post, you can…

  • Using SQL like Excel

    Using SQL like Excel

    SQL allow you to manage a result set as a spreadsheet. It is possible using the MODEL clause.

  • MATCH_RECOGNIZE order of application

    MATCH_RECOGNIZE order of application

    Starting 12c, Oracle introduced THE MATCH_RECOGNIZE analytic function to recognize patterns. IF you are NEW TO this…

  • ITOUG Tech Day 2019 (Milano)

    ITOUG Tech Day 2019 (Milano)

    Il primo giorno del Tech Day 2019 a Milano, si è concluso. Alla grande dire.

    2 条评论
  • ITOUG 2019: Oracle, Mediamente, R1

    ITOUG 2019: Oracle, Mediamente, R1

    L'ITOUG event che si terrà il 30/Gennaio/2019 a Milano ed il 01/Febbraio/2019 a Roma è stato possibile grazie a tre…

  • ITOUG 2019: ancora insieme

    ITOUG 2019: ancora insieme

    Ormai ci abbiamo preso gusto. E' bello iniziare un nuovo anno (più o meno :) sapendo che poi sarà tutto in discesa.

  • ITOUG 2019 Thech Days

    ITOUG 2019 Thech Days

    Finalmente ci siamo. il 30 Gennaio ed il 1 Febbraio IOTUG organizzerà un nuovo evento.

  • Blocking session

    Blocking session

    Some time ago, I wrote a post on how to show a chain of blocked sessions. In this days Kaley Crum wrote a new version…

社区洞察

其他会员也浏览了