From the course: SQL for Statistics Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

ROW_NUMBER

ROW_NUMBER

- [Lecturer] Sometimes, it helps to assign a value to a position of a row in a sorted list of values. The row number function is used for that. Row number is a window function, which means it operates over an ordered set. So for example, we can order rows by the number of units sold, using this statement, row number, which is the function, and we want to specify that as being over the ordered by set of units sold. So this would be a column that we insert into a select statement. So let's do that. Let's say select and let's select the various things that we want to include in this query. We want to have our sale date, the month of the year, and the units sold, and we'll select to solve from store sales. Now let's notice the results here. The select statement lists data about sales ordered by the number of units sold in increasing order. Notice the first five rows are for months one, nine, 10, and 12. This technique is useful when we want to assign a value based on ordered in the list…

Contents