🎉 SQLFluff Online 🎉

SQLFluff is a SQL formatter that is implemented in Python. You can use this app to format one-off, adhoc sql that might not be worth saving to a file. Or you can use it to see what SQLFluff thinks of your queries. It's up to you!

You can check out the source code for this application on GitHub (click).

Paste your SQL and select your dialect. Hit that button and find your fixed SQL with the associated linter errors. Enjoy, friends 🌝.


Your Terrible SQL



SQLFluff is maintained by a group of talented attractive and selfless people who are all driven by a common disdain for poorly formatted SQL. If you like fluff's treatment of your queries, feel encouraged to check out our group on GitHub!

This app runs on SQLFluff version 3.0.7, and applies all rules in that version. Here is a list of them:

Rule Description
AL01 Implicit/explicit aliasing of table.
AL02 Implicit/explicit aliasing of columns.
AL03 Column expression without alias. Use explicit `AS` clause.
AL04 Table aliases should be unique within each clause.
AL05 Tables should not be aliased if that alias is not used.
AL06 Enforce table alias lengths in from clauses and join conditions.
AL07 Avoid table aliases in from clauses and join conditions.
AL08 Column aliases should be unique within each clause.
AL09 Column aliases should not alias to itself, i.e. self-alias.
AM01 Ambiguous use of 'DISTINCT' in a 'SELECT' statement with 'GROUP BY'.
AM02 'UNION [DISTINCT|ALL]' is preferred over just 'UNION'.
AM03 Ambiguous ordering directions for columns in order by clause.
AM04 Query produces an unknown number of result columns.
AM05 Join clauses should be fully qualified.
AM06 Inconsistent column references in 'GROUP BY/ORDER BY' clauses.
AM07 Queries within set query produce different numbers of columns.
CP01 Inconsistent capitalisation of keywords.
CP02 Inconsistent capitalisation of unquoted identifiers.
CP03 Inconsistent capitalisation of function names.
CP04 Inconsistent capitalisation of boolean/null literal.
CP05 Inconsistent capitalisation of datatypes.
CV01 Consistent usage of '!=' or '<>' for "not equal to" operator.
CV02 Use 'COALESCE' instead of 'IFNULL' or 'NVL'.
CV03 Trailing commas within select clause.
CV04 Use consistent syntax to express "count number of rows".
CV05 Comparisons with NULL should use "IS" or "IS NOT".
CV06 Statements must end with a semi-colon.
CV07 Top-level statements should not be wrapped in brackets.
CV08 Use 'LEFT JOIN' instead of 'RIGHT JOIN'.
CV09 Block a list of configurable words from being used.
CV10 Consistent usage of preferred quotes for quoted literals.
CV11 Enforce consistent type casting style.
JJ01 Jinja tags should have a single whitespace on either side.
LT01 Inappropriate Spacing.
LT02 Incorrect Indentation.
LT03 Operators should follow a standard for being before/after newlines.
LT04 Leading/Trailing comma enforcement.
LT05 Line is too long.
LT06 Function name not immediately followed by parenthesis.
LT07 'WITH' clause closing bracket should be on a new line.
LT08 Blank line expected but not found after CTE closing bracket.
LT09 Select targets should be on a new line unless there is only one select target.
LT10 'SELECT' modifiers (e.g. 'DISTINCT') must be on the same line as 'SELECT'.
LT11 Set operators should be surrounded by newlines.
LT12 Files must end with a single trailing newline.
LT13 Files must not begin with newlines or whitespace.
RF01 References cannot reference objects not present in 'FROM' clause.
RF02 References should be qualified if select has more than one referenced table/view.
RF03 References should be consistent in statements with a single table.
RF04 Keywords should not be used as identifiers.
RF05 Do not use special characters in identifiers.
RF06 Unnecessary quoted identifier.
ST01 Do not specify 'else null' in a case when statement (redundant).
ST02 Unnecessary 'CASE' statement.
ST03 Query defines a CTE (common-table expression) but does not use it.
ST04 Nested 'CASE' statement in 'ELSE' clause could be flattened.
ST05 Join/From clauses should not contain subqueries. Use CTEs instead.
ST06 Select wildcards then simple targets before calculations and aggregates.
ST07 Prefer specifying join keys instead of using 'USING'.
ST08 'DISTINCT' used with parentheses.
ST09 Joins should list the table referenced earlier/later first.
TQ01 'SP_' prefix should not be used for user-defined stored procedures in T-SQL.