SQL
select o.id, c.name, sum(oi.qty*oi.price) as total from orders o join customers c on c.id=o.customer_id left join order_items oi on oi.order_id=o.id where o.created_at >= '2026-01-01' and c.country in ('US','CA') group by o.id, c.name having sum(oi.qty*oi.price) > 100 order by total desc limit 50;
Formatted
Dialect
Standard SQL
MySQL
MariaDB
PostgreSQL
SQL Server (T-SQL)
Oracle PL/SQL
SQLite
BigQuery
Snowflake
Redshift
Keyword case
UPPERCASE
lowercase
Preserve
Indentation
2 spaces
4 spaces
Tabs
Blank lines between statements
1
2
Copy formatted SQL
Powered by
SnagATool
— Free SQL Formatter