Skip to content Skip to sidebar Skip to footer
Showing posts with the label Common Table Expression

How To Sort Parents And All Siblings Using Cte For Adjacency List?

This is my table: CREATE TABLE IF NOT EXISTS NODE ( UUID VARCHAR NOT NULL, PARENT_UUID VA… Read more How To Sort Parents And All Siblings Using Cte For Adjacency List?

Sql How To Split Quantity Into Multiple Rows Based On Quantity On Target Source

I have two table where i want to join and show quantity with details. table are join with ITM,DIA ,… Read more Sql How To Split Quantity Into Multiple Rows Based On Quantity On Target Source

Remove Duplicates From A Table And Re-link Referencing Rows To The New Master

I have a table transcription which contains passages of transcribed text and their citations with c… Read more Remove Duplicates From A Table And Re-link Referencing Rows To The New Master

Traverse Through All Foreign Keys In Database And Generate A Path

I wrote a query to find out primary key - foreign key relationship between all the tables in a data… Read more Traverse Through All Foreign Keys In Database And Generate A Path

Using A Cte To Split Results Across A Cross Apply

I have some data that I need to output as rows containing markup tags, which I'm doing inside a… Read more Using A Cte To Split Results Across A Cross Apply

Cte Vs. T-sql Loop For Determining Depth Of Object Hierarchy

I have a table consisting of about 70,000 rows and two columns (both VARCHAR(16)): id and parent_id… Read more Cte Vs. T-sql Loop For Determining Depth Of Object Hierarchy

Insert Into A Temp Table In A Cte

I am trying to insert data into a temp table within a CTE. Here is the Code I am using: Can someo… Read more Insert Into A Temp Table In A Cte

Group By & Sum Of Values With Missing Months

I have gone through a lot of examples and joined couple of them in order to come down to the follow… Read more Group By & Sum Of Values With Missing Months

Returning All Children With A Recursive Select

Good day everyone! I've got a graph. First, I know how to build simple recursive selections. I … Read more Returning All Children With A Recursive Select

Sql Server Cte Left Outer Join

I have 2 tables in SQL Server 2008, customertest with columns customer id (cid) and it's boss i… Read more Sql Server Cte Left Outer Join

How To Get Previous And Current Row Value Using Recursive Cte?

Consider the below Id Nums 1 10 2 20 3 30 4 40 5 50 The expected output Id CurrentValu… Read more How To Get Previous And Current Row Value Using Recursive Cte?

Sum Of Child Levels Total In A Hierarchy

I need to have each level be the sum of all children (in the hierarchy) in addition to any values s… Read more Sum Of Child Levels Total In A Hierarchy

Using A Cursor With A Cte

I need a cursor for the below query so I can loop through to fetch/update/insert some other data. C… Read more Using A Cursor With A Cte

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… Read more Passing A Record As Function Argument Pl/pgsql

Sys_connect_by_path Equivalent In T-sql

I need to convert my Oracle query into SQL Server. The query generates a 'management hierarchy&… Read more Sys_connect_by_path Equivalent In T-sql

Concatenating Single Column In Tsql

I am using SSMS 2008 and trying to concatenate one of the rows together based on a different field&… Read more Concatenating Single Column In Tsql

How To Use Common Table Expression And Check No Duplication In Sql Server

I have a table references to itself. User table: id, username, managerid and managerid links back t… Read more How To Use Common Table Expression And Check No Duplication In Sql Server

Eliminate Row That Has Null Value Using Cte

I have some data as RowIdentifier ID RowID Position Data Rn 1 1 1 … Read more Eliminate Row That Has Null Value Using Cte

Creating View From Related Child Tables

I have the following general table structure (forgive the United States-centric carmakers in my con… Read more Creating View From Related Child Tables

Tree Structure And Recursion

Using a PostgreSQL 8.4.14 database, I have a table representing a tree structure like the following… Read more Tree Structure And Recursion