Okay. So, you may not remember what a windowing function is. This is something that should have been covered in a previous class but when I haven't used this in a while, I need to remind myself of the syntax, too. Depending on the version of SQL you're using, you may have some additional or different functionality. But by the end of this lesson, you'll remember what a windowing function is and you'll be able to decide which one is the right one for your task. So, let's go through a quick task to drug your memory. So, let's go through a quick task to drug our memory. I'd like to pull a subtable of just the first order that a user ever made. Maybe I could look at the orders by user and date. Maybe I could sort them using the order by clause, like this. But if you try it, you'll find that this doesn't actually work. The group by clause doesn't really work without an aggregation function. So, I guess I could use the minimum function to get the minimum date for the order and then join the table to itself. I'm not sure that would generalize very well. It turns out that this is a pretty common need and there's a tool for it in SQL. What we're really asking for here is to partition or window this query based on the user ID, and then we can number the orders. We need a windowing function. So, here, I've written out a bunch of windowing functions: rank, DENSE_RANK, and row number. In all of them, I've partitioned by user ID and ordered the query by date. Copy the code here, run it, and see what it does. They're all slightly different. You can also check to make sure I'm not doing any silly mistakes like using ascending instead of descending. This will be hopefully helpful to understand what these functions actually do. Okay. Let's get back to our problem. Which one of these functions makes the most sense here? Make sure you're paying attention to how these functions handle the fact that we often have multiple rows per invoice. Here, DENSE_RANK numbers all of the items on the first invoice the same, and correctly labels all of the items on the second invoice with the number two. Okay. So, DENSE_RANK it is for this one. Then, my instinct would be to put in a WHERE clause to just get the first one. But remember that the column doesn't exist where the where statement is red. So, you're going to have to do that outside of a subquery. There's also a lot of other windowing functions. You can use existing functions like sum to get a cumulative sum of things, and the functions that you have available can vary between different flavors of SQL. So, if your Google Search gives you an example and that doesn't work, try adding in the environment name of your SQL variant and hopefully, you'll find the right way to window in your environment. All right. Good luck.