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.

Redshift INSERT INTO TABLE from CTE

According to the Redshift WITH Clause documentation, you can use a WITH clause with a INSERT INTO...SELECT statement. However …

sql amazon-web-services common-table-expression amazon-redshift
How to save a queried CTE output into a temporary table or table variable

I have a CTE and query this one ;With CTE_Table as (SELECT ...) Select * from CTE_Table Now I try …

sql tsql common-table-expression sql-server-2014 table-variable
Recursive query used for transitive closure

I've created a simple example to illustrate transitive closure using recursive queries in PostgreSQL. However, something is off with my …

sql postgresql common-table-expression recursive-query transitive-closure-table
How To Get All children and itself from Hierarchical data with CTE In SQL Server 2005 using stored procedure

I have many similar structure tables like this: CREATE TABLE [dbo].[tbl_Hierarchy]( [ID] [int] NOT NULL, [ParentID] [int] NOT …

sql-server stored-procedures common-table-expression hierarchical
CTE,Temp table and table variable

Can any one please tell me where to use CTE, temp table and table variable? I read about their differences …

common-table-expression sql-server-2014 temp-tables table-variable
recursive path aggregation and CTE query for top-down tree postgres

I'm trying to write a query to produce a list of all nodes in a tree given a root, and …

postgresql common-table-expression recursive-query
How to use WITH CLAUSE ...INSERT query in SAP HANA?

Here I used With AS Clause.if i use SELECT query it is working fine but if i use insert …

sql sql-insert common-table-expression hana
Using WITH + DELETE clause in a single query in postgresql

I have the following table structure, for a table named listens with PRIMARYKEY on (uid,timestamp) Column | Type | Modifiers ----------------+…

sql postgresql common-table-expression dml
CTE to traverse back up a hierarchy?

I can find all the children of a given record in a hierarchical data model (see code below) but I'm …

sql linq-to-sql hierarchy common-table-expression