At the 6:30 mark i was really curious if you were going to show me a way to not have to write recursive CTE’s. I was relieved to find out I wasn’t crazy and that recursion might be the time when CTE’s are the right tool. Thoroughly enjoyed this one.
@ErikDarlingData10 күн бұрын
Ha ha, I wish there were an alternative! Alas, we are stuck with them here.
@ScorpionJL9 күн бұрын
I do happen to find CTE's more readable because I hate multiple levels of indentation. I also tell everyone to treat them as views which would also execute the SQL once for each reference. On that note, I also do only use them in specific scenarios... 1. Using a merge statement from a staging (multi-tenant)table to filter the rows needed in a destination table 2. When aggregating data and stacking the queries, such as getting dataset1, dataset2, then doing a full join to see what variances exist.
@ErikDarlingData9 күн бұрын
As long as their use is reasonable and informed, I don't mind.
@Cahangir8 күн бұрын
Subscribed. Will hopefully dive deep when the time comes.
@ErikDarlingData8 күн бұрын
Well thanks, and welcome aboard!
@ScorpionJL9 күн бұрын
Another question... at 23:50 did a Sleestak enter the room?
@ErikDarlingData9 күн бұрын
And I lived to tell about it!
@caparn10010 күн бұрын
11:20 Doesn't _row_number()_ start at 1? So saying where n.n = 0 will always be false.
@ErikDarlingData10 күн бұрын
Yes, that’s the entire point.
9 күн бұрын
CTEs are terrible to debug, so I don't know how they are readable. Like 8+ chained CTEs inside a stored procedure where there is no reason not to use temp tables is my favourite.
@ErikDarlingData9 күн бұрын
Everyone looks at their own code and thinks it’s readable, even when it looks like a natural disaster.
@chrismettler1369 күн бұрын
yes, wish QUALIFY , MATERIALIZED as in postgresql/duckdb would be supported. Oracle is way better at optimizing/rewriting CTE. If MS thinks that theire AI is so great, why don't they use it to improve sql server ..
@ErikDarlingData9 күн бұрын
I don’t think they think it’s great, it’s just what everyone is getting memed into caring about at the moment. Eventually they’ll get over it and something new will take its place.
@FlaggedStar10 күн бұрын
Let me see if I've understood this: you're saying that CTEs aren't evil, but people wrongly think that they do good that they don't actually do?
@ErikDarlingData10 күн бұрын
Yes, like most other things, people believe meme nonsense they’ve heard and not what the reality is. Low information developers.
@mattcargile8 күн бұрын
Well recursive CTEs on parent and child relationship tables are more advanced.
@ErikDarlingData8 күн бұрын
More advanced than what?
@mattcargile8 күн бұрын
@ more advanced than a derived table I suppose. It was a comment from the beginning of the video. I see you discuss recursion at the end.