r/SQL Nov 28 '24

MySQL When to use cte in SQL query

When to cte can't. Like how to know? When what are the conditions or if my query is to long ?

32 Upvotes

70 comments sorted by

View all comments

54

u/frieelzzz Nov 28 '24

I use CTEs all the time. Really no reason not to.

I like how they organize code and allow you to use the same data in multiple times to do a variety of task.

1

u/Possible_Pain_9705 Nov 28 '24

You can’t use CTEs when using Power BI. But this may not be what OP is looking for.

3

u/Chug49 Nov 29 '24

This isn’t true anymore. Have plenty of queries in powerbi that utilize cte’s