DronaBlog

Tuesday, January 25, 2022

What is RANK function in Oracle database ?

               Are you looking for an article on the Rank function in the Oracle database? Are you also interested in knowing how to use the RANK function in SQL? If so, then you reached the right place. In this article, we will learn the RANK function in detail Let's start.


A) What is the RANK function?

              The RANK is an analytic function in oracle we use the RANK function to get the rank of a value in a group of values. The RANK  function can be used both as an aggregate and as an analytic function.






B) Using RANK function as an aggregate function 

             We need to use the following syntax in order to use the RANK function as an aggregate function 

             RANK (Expression_1 , Expression _2 .......Expression_n)

                           WITHIN GROUP

                          (ORDER BY Expression_1 , Expression_2......Expression_n)

             In the above syntax, Expression _1 , Expression_2 are used to determine the unique row in the group.

 





C) Using RANK function as an Analytic function 

              We need to use the following syntax in order to use RANK function as Analytic function -

              RANK ( ) OVER ( [ query - partition _clause ]

                                             ORDER BY clause )

             In above syntax -

            Order By clause - is an optional parameter and is used to order the data within each group.

            query-partition_clause - it is an optional parameter and is used to partition results set into groups.


D) DENSE_RANK in oracle 

               The DENSE_RANK in oracle determines the rank of a row in an ordered group of rows and returns rank as Number Rank values are not skipped in the event of ties. If values are the same then the same rank number is given.


                  Learn more about oracle here - 



No comments:

Post a Comment

Please do not enter any spam link in the comment box.

What are top cloud data warehouses ?

            Are you looking for the top cloud data warehouses in the current market? Are you interested in knowing which cloud data warehous...