3 ms·
Yes, CTE's are a much more readable than subqueries IMO. I can't really explain it but it just makes queries easier to build and read to me.
by cwbriscoe 2y ago
Yes, CTE's are a much more readable than subqueries IMO. I can't really explain it but it just makes queries easier to build and read to me.
- fifilura 2y agoTwo benefits: 1) The flow is clearer: take this, then transform this, then filter this 2) CTEs makes it easy to debug parts. You just change what you select from on the last line. Number 2 is the kicker IMO
- disgruntledphd2 2y agoAnd this is why you should always, always have a `final` CTE and the last line should be `select * from final` so that you can easily change this. We use a LOT of SQL at $current_dayjob and I almost always end up adding this to the queries. Clearly I need to do a better job of evangelising my approach.
- deleted 2y ago[deleted]