Working with SQL

Advanced SQL and best practices.

Best practices for writing SQL queries

SQL best practices: a brief guide to writing better SQL queries.

13 min read

Simplify complex queries with Common Table Expressions (CTEs)

CTEs are named sets of results that help keep your code organized. They allow you to reuse results in the same query, and perform multi-level aggregations.

5 min read

Working with dates in SQL

Use SQL to group results by a time period, compare week-over-week totals, and find the duration between two dates.

9 min read

How to calculate customer lifetime value (LTV) with SQL

Learn how to use SQL to calculate customer lifetime value in Metabase.

5 min read

SQL syntax reference

How does that SQL keyword work again?

6 min read