当查询嵌套子查询过多时,通常采用建立虚表的方式,将比多次查询部分查询出来作为虚表。
在进行汇总的同时采用union all ,提高效率。
如
with t as (select colxx from table ....)--虚表
select sum(t.one),sum(t.two)
from t
union all
select t.one,t.two
from t
在进行汇总的同时采用union all ,提高效率。
如
with t as (select colxx from table ....)--虚表
select sum(t.one),sum(t.two)
from t
union all
select t.one,t.two
from t