`
phoebird
  • 浏览: 113860 次
  • 性别: Icon_minigender_1
  • 来自: 重庆
社区版块
存档分类
最新评论

SQL优化

SQL 
阅读更多
    当查询嵌套子查询过多时,通常采用建立虚表的方式,将比多次查询部分查询出来作为虚表。
在进行汇总的同时采用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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics