Row Number Window Function | First Occurrence In A Series

Using the Row Number Window Function to flag records if that row is the first occurrence in a series is a performant way to extract more value from your data. By using a Partition By clause we can group chunks of data together while ordering them to figure out which is the first in that series of data. Row Number, with the addition of the Over clause, allows us to achieve this without the use of a subquery by simply wrapping the function in a case statement.

A meme of how we put the fun in window functions!
A meme of how we put the fun in row number window functions!

An example of how to find the first occurrence in a series

Continue reading →