JournalSQLQuery structure1 min

Order of clauses in SQL

Noting that the square brackets [ ] means optional.

  • SELECT
  • FROM
  • WHERE
  • GROUP BY
  • ORDER BY
[ WITH <common_table_expression>]

SELECT select_list [ INTO new_table ]

[ FROM table_source ] [ WHERE search_condition ]

[ GROUP BY group_by_expression ]

[ HAVING search_condition ]

[ ORDER BY order_expression [ ASC | DESC ] ]

Noting that the square brackets [ ] means optional.

References: