IntermediateWHERE & Filtering
Find orders placed in the last 30 days
The query
SQL
SELECT order_id, cust_id, order_date, total
FROM orders
WHERE order_date >= NOW() - INTERVAL '30 days'
ORDER BY order_date DESC;Note
“INTERVAL arithmetic is elegant in PostgreSQL. Alternatives: CURRENT_DATE - 30.