SELECT u.id,
u.username,
u.email,
o.order_id,
o.total_amount,
o.created_at,
SUM (
p.price * oi.quantity
) AS calculated_total
FROM users u
INNER JOIN orders o
ON u.id = o.user_id
LEFT JOIN order_items oi
ON o.order_id = oi.order_id
LEFT JOIN products p
ON oi.product_id = p.id
WHERE u.status = 'active' AND o.created_at >= '2026-01-01' AND (
o.payment_status = 'paid' OR o.payment_status = 'settled'
)
GROUP BY u.id,
o.order_id
HAVING calculated_total > 500
ORDER BY o.created_at DESC,
calculated_total DESC
LIMIT 50;Pin this tool to your browser side panel
Access this utility anytime with Alt+M without switching tabs. 100% offline & free.
How to format and beautify SQL queries
- 1Paste your unformatted SQL query into the left code editor or click 'Load Sample'.
- 2Toggle 'Uppercase Keywords' to normalize statements (e.g. SELECT, FROM, WHERE, JOIN).
- 3Choose your preferred indentation spacing (2 spaces or 4 spaces).
- 4Click 'Copy Formatted SQL' to immediately paste into your database IDE or repository.
100% Confidential Local Parsing
Database queries containing confidential table schemas, user IDs, or company financial data are processed entirely inside browser memory.
Architecture & Privacy
- 100% Client-Side In-Browser Formatter: Protects confidential table names, column schemas, and internal database IPs from server uploads.
- Multi-Dialect Support: Formats standard ANSI SQL, MySQL, PostgreSQL, SQLite, and MariaDB queries.
- Clause Hierarchy Alignment: Breaks major clauses (FROM, JOIN, WHERE, HAVING, ORDER BY) into clean, aligned blocks.
- One-Click SQL Minifier: Strips excess whitespace and newlines for high-performance query string transport.
Frequently Asked Questions
Enjoying SQL Formatter & Beautifier?Help your engineering peers discover private, ad-free tools!
MiniToolDesk is 100% free and client-side. Your support keeps the web ad-free.
Related Developer Utilities
JWT Debugger & Decoder
Safely decode, verify, and inspect JSON Web Tokens (JWT) payload and headers in local memory
YAML to JSON Converter
Convert YAML to JSON and JSON to YAML bidirectionally with real-time validation
Developer & Tech Unit Converter
Convert Data Storage (KB/KiB, MB/MiB, GB/GiB), CSS units (px to rem), Length, Speed, and Temp
World Timezone & Meeting Planner
Interactive 24-hour global city time synchronizer and remote team meeting planner