SQL Mastery: Advanced Techniques for Data Professionals | by Mia Dwyer | Apr, 2024

Elevating Your Data Skills with Window Functions, Regex, and CTEs

During my tenure as a lead data analyst at Chime, three crucial SQL techniques— Window Functions, Regex, and CTEs — significantly advanced my capabilities, propelling me from intermediate proficiency to the expertise required for a lead analyst role. This article details these so you can up-level your skills and unlock new dimensions in data exploration.

Image created by me, using DALL-E

A window function (or analytic function) makes a calculation across multiple rows that are related to the current row, and lets you calculate things like:

  • Rankings
  • Running totals
  • 7-day moving averages (i.e. average values from 7 rows before the current row)

Creating rankings with window functions is an extremely powerful tecnique in analytics and data science. Consider for this transactions dataset, where we have transactions made by customers.

A sample transaction table screenshot, dummy data created by me using ChatGPT.

Ranking Window Functions: