I am trying to write a statistic about the data warehouse tables that are used.
Therefor I should make a query to bring the used tables.
I have a list of table n
Here is the solution that I searched for:
WITH dwtables(dwtable) AS (
SELECT 'DWA' FROM dual UNION ALL
SELECT 'DWB' FROM dual UNION ALL
SELECT 'DWC' FROM dual
)--> Tabelle mit einem Spalte (Liste)
SELECT title,
(SELECT LISTAGG (dwtable, ', ' ) WITHIN GROUP (ORDER BY dwtable)
FROM dwtables
WHERE REGEXP_LIKE (r.querytext, '(^|\s)'||dwtables.dwtable||'(\s|$)', 'i')) AS dwtables
FROM Reports r;