What the WITH? Care and feeding of CTEs

Short Form


Have you tried some recursion in your SQL? In this session, we will go over the concept of Common Table Expressions (CTE), also known as WITH queries. We will explore syntax, features, and use cases for this powerful SQL construct.


There are some use cases for which plain SQL might not be enough; you need to use recursion, but don’t know how. Common Table Expressions may be able to help!

In this session, we will use PostgreSQL to introduce the attendees to Common Table Expressions. We will go over their syntax, view their results, and discuss best practices and use cases for this powerful SQL feature.


database, SQL, PostgreSQL, Postgres, cte

Speaking experience

I have spoken at three OSBridge conferences, two OSCONs, and a PGCon. This would be the first time this talk has been presented.


  • Brewer

    Michael Alan Brewer

    The University of Georgia


    Michael Brewer is a Web Developer Principal for the Franklin College Office of Information Technology at The University of Georgia. He designs database-backed web applications used by thousands of students and faculty and has served on several college and University-wide committees on Web development, best practices, and application security. In 2005, he won an Advising Technology Innovation Award from the National Academic Advising Association for an academic advising application he maintains; he also serves on the board of the United States PostgreSQL Association. He holds bachelor degrees in both Mathematics and Music from The University of Georgia, conducts Georgia’s oldest continuously-operating community band, is Director of Music at Emmanuel Episcopal Church (Athens, GA), and is a member of ASCAP.