Learn Working with SQL Topic Working with SQL Using SQL in Metabase. Articles Article 1 Best practices for writing SQL queries SQL best practices: a brief guide to writing better SQL queries. Read more Article 2 Create filter widgets for charts using SQL variables How to create filter widgets in native SQL queries using basic input variables for text, numbers, and dates. Read more Article 3 Field Filters: create smart filter widgets for SQL questions Learn how to use Metabase Field Filters in SQL queries to build filter widgets. Read more Article 4 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. Read more Article 5 SQL snippets: reuse and share SQL code Learn everything you need to know about using snippets in SQL code. Read more Article 6 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. Read more Article 7 SQL Snippets vs. Saved Questions vs. Views Learn about the Metabase features you can use to keep your SQL code organized. Read more Article 8 Combining tables with joins How to combine information from two tables with a join. Read more Article 9 SQL join types Learn everything you need to know about using different SQL join types. Read more Article 10 SQL trick: ordering bars in a chart A simple trick to preserve the order you want the bars to appear in a chart. Read more Article 11 How to calculate customer lifetime value (LTV) with SQL Learn how to use SQL to calculate customer lifetime value in Metabase. Read more