Top "Common-table-expression" questions

A Common Table Expression (CTE) is a temporary result set that is defined within the execution scope of a single SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement.

Can I use WITH in TSQL twice to filter a result set like my example?

I need to do something like this but SQL Server 2008 doesn't like it. My query is actually more complex than …

sql sql-server common-table-expression
How to create CTE which uses another CTE as the data to further limit?

I have searched this question here but couldn't find it, please redirect me if we already have it on the …

sql common-table-expression
Common Table Expression (CTE) in linq-to-sql?

Is it possible to do common table expressions (CTE) (like shown below) in Linq to SQL. I'm pretty new to …

linq-to-sql common-table-expression
Why Oracle connect by with nocycle follows root cycle

Does anyone know why Oracle continues to follow a path beyond a cyclical loop when the cycle occurs at the …

sql oracle11g hierarchy cycle common-table-expression
Passing a record as function argument PL/pgSQL

First I am really new to pl/pgsql. Need it for a project. I am stuck with this (simplified) problem. …

postgresql types plpgsql common-table-expression sql-insert
Why cannot we use outer joins in Recursive CTE?

Consider the below ;WITH GetParentOfChild AS ( SELECT Rn = ROW_NUMBER() Over(Order By (Select 1)) ,row_id AS Parents ,parent_account_…

sql-server-2005 common-table-expression
Common Table Expression in Sub-Query

I would request for help in understanding which all RDBMS from Oracle, DB2, Sybase support a common table expression (CTE) …

oracle postgresql db2 sybase common-table-expression
T-SQL: CTE with identity columns

I'm building a tree (bill of materials style), and transforming some data. Consider the following table: BillOfMaterials BomId ParentId Now …

sql-server-2008 common-table-expression identity-column
Common Table Expression, why semicolon?

Usually in SQL Server Common Table Expression clause there is semicolon in front of the statement, like this: ;WITH OrderedOrders …

sql sql-server tsql sql-server-2008 common-table-expression
CTE and FOR XML to generate nested XML

I have an adjacency list in the DB and want to deliver the data in XML format to the client …

sql-server xml tsql common-table-expression for-xml