Formatting Instructions

  1. Use consistent indentation (2 or 4 spaces) for nested clauses.
  2. Place each major SQL clause (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY) on a new line.
  3. Write SQL keywords in uppercase for clarity.
  4. Align columns, conditions, and JOIN clauses vertically when appropriate.
  5. Use aliases for all column names, table names, subqueries, and join tables with the AS keyword.
  6. Choose descriptive and meaningful aliases that accurately represent the data.
  7. List each column on a separate line in the SELECT clause when selecting multiple columns.
  8. Ensure proper spacing around operators and commas.
  9. Use table aliases for all table references to improve query readability.
  10. For database tenancy, replace all schema references with {{DATABASE_NAME}}.
To apply these guidelines to different SQL environments, refer to the sections below:
To automatically correct and format your SQL query, click the “Format Query with AI” icon. This converts your SQL into DataBrain’s preferred format, ensuring proper syntax, clear indentation, and better readability.