From the course: Presto Essentials: Data Science
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Window functions - Presto Tutorial
From the course: Presto Essentials: Data Science
Window functions
- [Instructor] Sometimes when working with data, you're going to need to perform calculations that change across the span of time or other discrete values. A good example is a rank. If you wanted to calculate the rank of something. And these are known as window functions in SQL terms. Again, not many or not all data platforms support these more advanced functions, but Presto does regardless of whether or not the underlying database does. So let's dig in here and see some of these functions in action. First I want to find the highest ranked parts from my tiny database, the tpch benchmarking database. So I'll start by saying presto --server localhost logging in. And I want to run a function against this, so let's do select, and we'll do part key, extended price, which is the price listed, rank, this is our function, this is our window function. And when we do this we have to say over. What are we ranking over? Now we could partition this let's say by category or by year, but in this…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.