LESSON 1.3

CTEs and window functions

07:52·10,661 learners
Daniel OkaforDaniel Okafor
Next lesson

In this lesson you will

  • Break a complex query into named CTEs
  • Rank and number rows within partitions
  • Compute running totals and row-to-row differences

CTEs make a long query readable; window functions compute across related rows without collapsing them. Running totals and rankings stop being hard.

What this lesson covers

  • Break a complex query into named CTEs
  • Rank and number rows within partitions
  • Compute running totals and row-to-row differences

This lesson sits in SQL Essentials, part of PostgreSQL for Developers. It assumes what came before it and leads directly into the next lesson in the module.

PRO TIP

When you catch yourself writing a subquery inside a subquery, a CTE will make it readable.

UP NEXT

2.1 · Normalisation and when to break it

03:33

PostgreSQL for Developers

17%

Every lesson, searchable to the second.

© 2026 BIBLION

PRIVACY · TERMS · CONTACT