Quantcast
Channel: Active questions tagged cte - Database Administrators Stack Exchange
Browsing all 207 articles
Browse latest View live
↧

Image may be NSFW.
Clik here to view.

How to create multiple temp tables using records from a CTE that I need to...

I am already using a CTE expression within a plpgsql Procedure to grab some Foreign Keys from (1) specific table, we can call it master_table. I created a brand new table, we can call this table...

View Article


CTE Error (nvarchar to numeric)

I'm using a CTE to convert SSRS stored proc's into BO stored proc's, as apparently I can't use temp tables with Business Objects.I'm having this query:;WITH cte1AS( SELECT cv.issue , cv.customfield ,...

View Article


Caching intermediary CTEs for multiple uses

I'm working on this huge query that I chose to use CTEs. Due to the complexity of this query, I ended up having to reuse intermediary query results more than once in subsequent queries. The problem I'm...

View Article

How is the postgres actually getting some of the columns? Execution plan...

I've got a table with a bunch of columns. Among them facility_id and po_date. I'm writing a complex query and I have an index on those two columns. You can see from the planner output below that...

View Article

Image may be NSFW.
Clik here to view.

How can I group / display same date data in one row?

I have a table that gets inserted into every night that is a snapshot of the data. At any point in time, the data might change in the columns (AccountNo stays the same, RunKey is incremented by 1, and...

View Article


What are use cases for Recursive CTEs?

I am looking for examples of why you would use a recursive CTE, but the dozens of examples I have found in my web searching basically reduce to two:Generating a sequenceIterating through an employee...

View Article

If a CTE is defined in a query and is never used, does it make a sound?

Do unused CTEs in queries affect performance and / or alter the generated query plan?

View Article

Significance of $$ in MongoDB

I was recently given this snippet of code that generates an arbitrary document in MongoDB. I've never encountered $$ in Mongo before and I'm curious about its significance.All I know is that if I run...

View Article


Difference between a query based on CTE and a simple query

i'm doing a select starting from a table named events that is joined with device measurements using a date between function (this time between is a sort of "mobile windowing") in order to get the...

View Article


ON CONFLICT DO UPDATE command cannot affect row a second time when trying to...

Based on the SO: https://dba.stackexchange.com/a/46477 answer provided, I have been extending the Function with UPSERT in Postgres 9.5 or later for my own purposes to insert data into multiple...

View Article

Recursive CTE in PostgreSQL to generate data with different frequencies

I am trying to write a data generation query which uses recursive CTE in Postgresql 14.Consider schema "sc" which includes a function getfreq. getfreq takes an int as param (which represents a...

View Article

How to retrieve min/max values and corresponding dates in a table

I'm trying to figure how to retrieve minimum/maximum values and minimum/maximum dates from a data set, but also the date value that corresponds to each minimum/maximum value.Example Data:CREATE TABLE...

View Article

Using a CREATE TABLE AS SELECT how do I specify a WITH condition (CTE)?

There is an old and deprecated command in PostgreSQL that predates CREATE TABLE AS SELECT (CTAS) called SELECT ... INTO .... FROM, it supports WITH clauses / Common Table Expressions (CTE). So, for...

View Article


Image may be NSFW.
Clik here to view.

Generate WITH clause from resultset using SQL Developer?

I've run a query in Oracle SQL Developer 18.I want to share the resultset data on Stack Exchange in a format that's easy for answerers to grab and use.From my experience, WITH clauses are preferred by...

View Article

Can EXPLAIN be used to get some insights about Common Table Expression (CTE)?

I need to find the ancestors in a table having an ID value and a Google research point me to recursive Common Table Expression (CTE) I wonder if EXPLAIN can be used to get some insights on how MySQL...

View Article


Image may be NSFW.
Clik here to view.

How do I sort the results of a recursive query in an expanded tree-like fashion?

Let's assume you have a nodes tables like this:CREATE TABLE nodes ( node serial PRIMARY KEY, parent integer NULL REFERENCES nodes(node), ts timestamp NOT NULL DEFAULT now());It represents a standard...

View Article

How Many Times Does a CTE run

If I have a cte such as the below code. How many times does the table People get queried against? I was under the impression that it was only called 1 time and stored in memory but some of my queries I...

View Article


CTE clause not able to be used in final ORDER BY statement

Trying to order by distance using an input geometry t(x), while comparing to geometries from a JOINed table.WITH "nearest_groups" as ( SELECT groups.id, ST_Distance(t.x, locations.center) AS nearest...

View Article

Slow CTE update query

I have a query that is running for more than three hours without completing.I realized that the bad part is the Filter operator which has a cost of 89%.WITH FASES_NUMERADAS_CTE AS ( SELECT NUM_PROCES,...

View Article

Index converted from Seek to Scan in CTE

SQL Server version:Microsoft SQL Server 2019 (RTM-CU8-GDR) (KB4583459) - 15.0.4083.2 (X64)Nov 2 2020 18:35:09Copyright (C) 2019 Microsoft CorporationEnterprise Edition: Core-based Licensing (64-bit) on...

View Article
Browsing all 207 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>