我有多个使用相同数据子集的SELECT查询。我想重用它,所以没有重复的子查询或WITH子句。但是,由于权限不足,我无法创建TABLE或VIEW。那么有解决方法吗?
我正在使用TOAD Oracle。
例如,
WITH LOCAL_RESULTS
AS (SELECT a, b, c, d...
FROM SURVEY )
SELECT A, B
FROM LOCAL_RESULTS
where condition=1
WITH LOCAL_RESULTS
AS (SELECT a, b, c, d...
FROM SURVEY )
SELECT A, C
FROM LOCAL_RESULTS
where condition=2
WITH LOCAL_RESULTS
AS (SELECT a, b, c, d...
FROM SURVEY )
SELECT B, D, A...
FROM LOCAL_RESULTS
where condition=3
感谢您的帮助。
答案 0 :(得分:1)
联合查询可能有效。
with local_results as
(subquery goes here)
select a, b, c, 1 condition
from local_results
where whatever
union
select a, b, null c, 2 condition
from local_results
etc