Keyword Case:
UPPERCASE
lowercase
Preserve
Indent:
2 spaces
4 spaces
Sample Query
Clear
Raw SQL Query
select u.id, u.username, u.email, count(o.id) as total_orders, sum(o.amount) as total_spent from users u left join orders o on u.id = o.user_id where u.status = 'active' and o.created_at >= '2026-01-01' group by u.id, u.username, u.email having count(o.id) > 5 order by total_spent desc limit 50;
Formatted SQL
Download
Copy
SELECT u.id, u.username, u.email, COUNT(o.id) AS total_orders, SUM(o.amount) AS total_spent FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE u.status = 'active' AND o.created_at >= '2026-01-01' GROUP BY u.id, u.username, u.email HAVING COUNT(o.id) > 5 ORDER BY total_spent DESC LIMIT 50;