In the previous module, you learnt about and executed the ‘group by’ clause for collecting the facts about certain categories. Now, you may have noticed that using the ‘group by’ clause reduces the number of rows. It also leads to a loss of individual properties of various rows.
To address the two points mentioned above, i.e., reduction of rows and loss of individual properties of rows, SQL provides a special clause known the ‘over’clause, which displays group characteristics in the form of a new column. This leads to the preservation of the individual characteristics of different rows while displaying the group characteristics simultaneously. Let’s watch the upcoming video to understand the need for rank functions in SQL.
So, as you learnt in this video, the syntax used for writing a rank function is as follows:
Note
You will learn more about the ‘partition by’ clause later in this session. In the upcoming video, you will get a demonstration of window functions (also known as analytic functions). You will also understand the importance of ranking values based on the required criteria.
In this video, you learnt how to use rank functions with the help of some examples.
So, how well have you understood the use of rank functions? Test yourself by writing the query for the question given below.
There are some more rank functions which help in ranking values according to the given criteria. You will learn about them in the next segment.