I am just learning the CTE and I want to create the dynamic query inside the WITH clause.
Below is what i have written code.
WITH name1 AS (
SELECT schema_name as my_schema
FROM public.schema_table
), name2 AS (
SELECT num_rows as my_row
FROM my_schema.row_table
)
SELECT my_row
from name2;
From the first query inside the WITH give number of schema exist in one database and that schema name return by
SELECT schema_name as my_schema
FROM public.schema_table
I want to use in second query as I am saving it to my_schema.
but when i run this query then it gives me error like my_schema not exists that correct because I want to use the value my_schema contains.
How can you do that?