From the course: Introduction to SQL Using Google BigQuery
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Ranking functions - SQL Tutorial
From the course: Introduction to SQL Using Google BigQuery
Ranking functions
- [Instructor] The first window function implementation we'll cover is the rank function. In practice, this is used very often to sort outputs or to limit records based off certain criteria within different subsets of the data in a more sophisticated way than simply using limit with the order by clause. When implementing ranking window functions, the order by expression that is used in the over clause must be present. We can also use partition by expressions in the same over clause to create rankings within specific subgroups of the data. Some use cases for our Wisdom Pets case study might include finding the top selling products or highest performing customers, analyzing the latest transactions from customers based off some time dimension of recency or we can also identify the most purchased item for each customer based off the total quantity sold. We can also break up our rank implementation using a dummy toy version…