Formatting Instructions
- Use consistent indentation (2 or 4 spaces) for nested clauses.
- Place each major SQL clause (
SELECT
,FROM
,WHERE
,GROUP BY
,HAVING
,ORDER BY
) on a new line. - Write SQL keywords in uppercase for clarity.
- Align columns, conditions, and
JOIN
clauses vertically when appropriate. - Use aliases for all column names, table names, subqueries, and join tables with the
AS
keyword. - Choose descriptive and meaningful aliases that accurately represent the data.
- List each column on a separate line in the
SELECT
clause when selecting multiple columns. - Ensure proper spacing around operators and commas.
- Use table aliases for all table references to improve query readability.
- For database tenancy, replace all schema references with
{{DATABASE_NAME}}
.
Redshift
Redshift
Guideline 1: Use Aliases for ReadabilityAlways use aliases for column names, table names, subqueries, and join tables using the
AS
keyword. Aliases improve readability and make queries more concise.Guideline 2: Enclose Identifiers in Double Quotes ("
)Always use double quotes for column, table, and subquery names to avoid conflicts with reserved keywords and case-sensitive identifiers.Guideline 3: Reference Tables with the Database NameAlways prefix tables with the database and schema name to ensure clarity, especially in multi-schema databases.**Example Use **CaseSnowflake
Snowflake
Guideline 1: Use Aliases for ReadabilityAlways use aliases for column names, table names, subqueries, and join tables using the
AS
keyword. Aliases improve readability and make queries more concise.Guideline 2: Enclose Identifiers in Double Quotes ("
)Always use double quotes for column names to avoid conflicts with reserved keywords and case-sensitive identifiers.Guideline 3: Reference Tables with the Database NameAlways prefix tables with the database and schema name to ensure clarity, especially in multi-schema databases.Example Use CaseBigQuery
BigQuery
Guideline 1: Use Aliases for ReadabilityAlways use aliases for column names, table names, subqueries, and join tables using the
AS
keyword. Aliases improve readability and make queries more concise.Guideline 2: Enclose Identifiers in Double Quotes (`
)Always use backticks for column names to avoid conflicts with reserved keywords and case-sensitive identifiers.Guideline 3: Reference Tables with the Database NameAlways prefix tables with the database and schema name to ensure clarity, especially in multi-schema databases.MySQL
MySQL
**Guideline 1: **Use clear and consistent formatting**Guideline 2: **Write precise queries**Guideline 3: **Utilize column aliasesExample Use Case
PostgreSQL
PostgreSQL
Guideline 1: Use Aliases for ReadabilityAlways use aliases for column names, table names, subqueries, and join tables using the
AS
keyword. Aliases improve readability and make queries more concise.Guideline 2: Enclose Identifiers in Double Quotes ("
)Always use double quotes for column, table, and subquery names to avoid conflicts with reserved keywords and case-sensitive identifiers.Guideline 3: Reference Tables with the Database NameAlways prefix tables with the database and schema name to ensure clarity, especially in multi-schema databases.Example Use CaseMongoDB
MongoDB
Guideline 1: Use proper syntax for MongoDB collections and fieldsWhen querying MongoDB with SQL, wrap collection names and field names in square brackets to avoid syntax errors.Guideline 2: Utilize projections to return only necessary dataThis improves query performance by limiting the amount of data transferred and processed.Guideline 3: Leverage indexing for frequently queried fieldsCreate indexes on commonly searched fields to significantly enhance query performance
Elasticsearch
Elasticsearch
Guideline 1: Use Aliases for column namesGuideline 2: Do not use schema names
Databricks
Databricks
**Guideline 1: **Use specific column names instead of SELECT *This reduces the amount of data processed and transferred, speeding up queries.**Guideline 2: **Utilize WHERE clauses to filter rows earlyThis reduces the number of rows processed in later stages of the query, improving performance.Guideline 3: Implement proper indexingCreate indexes on frequently queried columns to drastically improve query performance.
ClickHouse
ClickHouse
**Guideline 1: Use Clear and Consistent Aliases for Columns and Tables **Use descriptive and consistent aliases (with
AS
) for column and table names to improve readability and simplify column references.Guideline 2: Enclose Identifiers in BackticksUse backticks around column and table names, especially if they contain spaces, special characters, or case sensitivity to avoid parsing errors.MSSQL
MSSQL
Guideline 1: Use Aliases for ReadabilityAlways use aliases for column names, table names, subqueries, and join tables using the
AS
keyword. Aliases improve readability and make queries more concise.Guideline 2: Enclose Identifiers in Double Quotes ("
)Always use double quotes for column, table, and subquery names to avoid conflicts with reserved keywords and case-sensitive identifiers.Guideline 3: Reference Tables with the Database NameAlways prefix tables with the database and schema name to ensure clarity, especially in multi-schema databases.Example Use CaseAwsS3
AwsS3
Guideline 1: Use Aliases for ReadabilityAlways use aliases for column names, table names, subqueries, and join tables using the
AS
keyword. Aliases improve readability and make queries more concise.Guideline 2: Enclose Identifiers in Double Quotes ("
)Always use double quotes for column, table, and subquery names to avoid conflicts with reserved keywords and case-sensitive identifiers.Guideline 3: Reference Tables with the Database NameAlways prefix tables with the database and schema name to ensure clarity, especially in multi-schema databases.Example Use CaseFirebolt
Firebolt
Guideline 1: Use Aliases for ReadabilityAlways use aliases for column names, table names, subqueries, and join tables using the
AS
keyword. Aliases improve readability and make queries more concise.Guideline 2: Enclose Identifiers in Double Quotes ("
)Always use double quotes for column, table, and subquery names to avoid conflicts with reserved keywords and case-sensitive identifiers.Guideline 3: Reference Tables with the Database NameAlways prefix tables with the database and schema name to ensure clarity, especially in multi-schema databases.Example Use CaseSingleStore
SingleStore
Guideline 1: Use Aliases for ReadabilityAlways use aliases for column names, table names, subqueries, and join tables using the
AS
keyword. Aliases improve readability and make queries more concise.Guideline 2: Enclose Identifiers in Backticks (`
)Database names, table names, and column names should be enclosed in backticks (`).Guideline 3: Reference Tables with the Database NameAlways prefix tables with the database and schema name to ensure clarity, especially in multi-schema databases.OpenSearch
OpenSearch
**Guideline 1: Use Clear and Consistent Aliases for Columns and Tables **Use descriptive and consistent aliases (with
AS
) for column and table names to improve readability and simplify column references.Guideline 2: Enclose Identifiers in BackticksUse backticks around column and table names, especially if they contain spaces, special characters, or case sensitivity to avoid parsing errors.