SQL: Common table expression (WITH)
A short, tested SQL example for common table expression (with). Copy it and adjust the names and paths for your project.
SQL
WITH recent AS (
SELECT * FROM orders WHERE created_at > NOW() - INTERVAL '30 days'
)
SELECT customer_id, COUNT(*) FROM recent GROUP BY customer_id;Find it in Zest
Search for “sql common table expression (with)” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.