Use the term, never define the term, classic. CTE stands for Common Table Expressions in SQL. They are temporary result sets defined within a single query using the WITH clause, acting like named subqueries to improve readability and structure.
Agreed. I was relieved to see this wasn’t written by Cam Skatteboro.
Good CTE, Bad CTE
21–30 of 47 posts
Re: Good CTE, Bad CTE
#22Re: Good CTE, Bad CTE
#23There's some good stuff in here. I didn't know about the issues an aggregation in a CTE can cause and haven't used EXISTS much. Regarding recursive CTEs, you might be interested in how DuckDb evolved them with USING KEY: https://duckdb.org/2025/05/23/using-key
Re: Good CTE, Bad CTE
#24Use the term, never define the term, classic. CTE stands for Common Table Expressions in SQL. They are temporary result sets defined within a single query using the WITH clause, acting like named subqueries to improve readability and structure.
OP here, damn - that's a very good point. Can't believe I missed it.
edit: syntax. voice to text was liberal with the comma abuse
Re: Good CTE, Bad CTE
#25Use the term, never define the term, classic. CTE stands for Common Table Expressions in SQL. They are temporary result sets defined within a single query using the WITH clause, acting like named subqueries to improve readability and structure.
OP here, damn - that's a very good point. Can't believe I missed it.
It'd be quite surprising the WITH statement in top a query to be the first feature to learn/use past basic SQL. Is it personal experience in some industry?
Re: Good CTE, Bad CTE
#26Embarassingly, despite thinking of myself as pretty knowledgeable with SQL, I had no idea you could nest DML statements inside a CTE. I always assumed/used DML statements as the final statement after a CTE was defined. I'm not sure if or when I might use this in the future, but it's neat to learn something new (and to be humbled at the same time).
Re: Good CTE, Bad CTE
#27Use the term, never define the term, classic. CTE stands for Common Table Expressions in SQL. They are temporary result sets defined within a single query using the WITH clause, acting like named subqueries to improve readability and structure.
This is a valuable comment, don't ruin it with sarcasm and rudeness.
Re: Good CTE, Bad CTE
#28Use the term, never define the term, classic. CTE stands for Common Table Expressions in SQL. They are temporary result sets defined within a single query using the WITH clause, acting like named subqueries to improve readability and structure.
Re: Good CTE, Bad CTE
#29Use the term, never define the term, classic. CTE stands for Common Table Expressions in SQL. They are temporary result sets defined within a single query using the WITH clause, acting like named subqueries to improve readability and structure.
Your comment could have been more helpful without the first sentence. SAME content, same correction, less superiority: "CTE is an overloaded term, in this article ......" This is a valuable comment, don't ruin it with sarcasm and rudeness.
no it wouldn't
the whole point is to critique the post
Re: Good CTE, Bad CTE
#30Earlier quoted context omitted.
From the headline, I thought it might be about sports-related concussions! I was morbidly curious what a "good CTE" could possibly be...
As someone who is not much of a sports person, now I was wondering what CTE means in sports. Seems to be this: > Chronic traumatic encephalopathy (CTE) is a progressive neurodegenerative disease […] > Evidence indicates that repetitive concussive and subconcussive blows to the head cause CTE. In particular, it is associated with contact sports such as boxing, American football, Australian rules football, wrestling, m…
The NFL in the US has famously gone to great lengths to downplay the impact of CTE on current and retired players. And there have been several famous players who literally lost their minds as they aged, and we now know that was due to CTE. Something like 90% of ex-NFLers have it. The number is still really bad for collegiate players. And even high school players are at risk.
It was to the point that Will Smith starred in a movie about it. https://en.wikipedia.org/wiki/Concussion_(2015_film)