Tuesday, 3 June 2008

SQL Snippet - Common Table Expressions

A Common Table Expression can be used to:-
  • Create a recursive query.
  • Substitute for a view when the general use of a view is not required; that is, you do not have to store the definition in metadata.
  • Enable grouping by a column that is derived from a scalar subselect, or a function that is either not deterministic or has external access.
  • Reference the resulting table multiple times in the same statement.
see Using Common Table Expressions and Recursive Queries Using Common Table Expressions

No comments: