Skip to content
Advertisement

Convert CTE Query into normal Query

I want to convert my @PostgreSQL, CTE Query, into Normal Query because the cte function is mainly used in data warehouse SQL and not efficient for Postgres production DBS. So, need help in converting this CTE query into a normal Query

Advertisement

Answer

You may just inline the CTE into your outer query:

Note that you have an unnecessary subquery in the CTE, which does an ORDER BY which won’t “stick” anyway. But other than this, you might want to keep your current code as is.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement