Format a grouped SQL query and check its literals
Admin ·
A readable layout lets you trace each selected column into the grouping or ordering clause. Choose the same dialect as the application that will consume the query.
Follow a grouped SQLite query
Paste select region, sum(total) as revenue from orders where state = :state group by region order by revenue desc; and choose SQLite. Select Uppercase and four spaces. The clauses move onto separate lines, the binding stays :state and grouping still uses region.
SQLite SELECT statement referenceSQL Formatter dialects and options
Check the boundary of a literal
Try select 'A B' as label; with two spaces between A and B. The internal spacing remains part of the string. For PostgreSQL, change dialect and try select $$A B$$::text; to keep a dollar-quoted string and its cast together.
Check the clauses that should stay together
Format a query with an OR condition inside parentheses and an AND condition outside them. Read the grouped expression before and after formatting. Consistent indentation makes it easier to review the parentheses but does not verify that the query selects the intended records.
Choose the dialect used by the database, then compare parameter markers and quoted identifiers. To confirm behavior, use the normal review and test process for the database that will execute it.
Common questions
Can the formatter tell whether an orders table exists?
The formatter handles source layout. Only the target database and its schema can resolve table names, privileges and column types.
How do I find a formatting failure?
Review the lexer or parser diagnostic against the source and the selected dialect. For example, an unterminated quoted value reports the position where tokenization failed.