1 Reply Latest reply: Feb 2, 2013 2:33 AM by stefan nebesnak RSS

    rank vs row_number

    user62721
      hi,

      I can't see the difference between analytic functions rank() and row_number()
      please, can you explain ?

      Thanks
        • 1. Re: rank vs row_number
          stefan nebesnak
          SQL RANK() versus ROW_NUMBER():
          http://stackoverflow.com/questions/7747327/sql-rank-versus-row-number
          select dense_rank() over (partition by b order by a) "dr",
                       rank() over (partition by b order by a) "rk",
                 row_number() over (partition by b order by a) "rn",
                        "a", "b"
          from some_table;
          
                  DR         RK         RN          A B
          ---------- ---------- ---------- ---------- ----------
                   1          1          1          4 #
                   1          1          2          4 #
                   1          1          3          4 #
                   2          4          4          8 #
                   2          4          5          8 #
                   1          1          1          2 *
                   1          1          2          2 *
                   2          3          3          3 *
                   2          3          4          3 *
                   3          5          5          5 *
                   3          5          6          5 *
                   3          5          7          5 *
          
          --source: http://www.adp-gmbh.ch/ora/sql/analytical/dense_rank_vs_rank_vs_row_number.html