Skip to content
Advertisement

Creating a CTE in Oracle

I am trying to create a CTE in Oracle that doesn’t select from an existing table but instead has data inserted into it. Currently, I am creating a table and then dropping it after the query is done. Is there a way to create a CTE that effectively does the same thing? This is my current code:

Advertisement

Answer

You can create your common table expression (CTE, subquery factoring, etc.) by selecting the date values from dual, and unioning them all together:

Not related to it being a CTE, but you can reduce the typing a bit by using date literals:

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