语句优化的问题!!!!
请问下面这条语句有什么办法可以优化下:
select code,descp,sum(money) sum_money
from ( select a.code,b.descp,sum(c.money*b.acount)money from table1 a,table2 b,table3 c
where a.code=b.code and b.descp=c.descp and .. group by a.code,b.descp
union all
select e.code,b.descp,sum(f.money*b.acount)money from table4 e,table5 f,table2 b
where e.code=b.code and b.descp=f.descp and .. group by e.code,b.descp
union all
select g.code,b.descp,sum(h.money*b.acount)money from table7 g,table8 h,table2 b
where g.code=b.code and b.descp=h.descp and .. group by e.code,b.descp
)group by code,descp
select code,descp,sum(money) sum_money
from ( select a.code,b.descp,sum(c.money*b.acount)money from table1 a,table2 b,table3 c
where a.code=b.code and b.descp=c.descp and .. group by a.code,b.descp
union all
select e.code,b.descp,sum(f.money*b.acount)money from table4 e,table5 f,table2 b
where e.code=b.code and b.descp=f.descp and .. group by e.code,b.descp
union all
select g.code,b.descp,sum(h.money*b.acount)money from table7 g,table8 h,table2 b
where g.code=b.code and b.descp=h.descp and .. group by e.code,b.descp
)group by code,descp
...全文
相关推荐
java代码-摇数字!!!!
java代码-摇数字!!!!
update 语句优化update 语句优化update 语句优化
update 语句优化
Verilog语言中case语句详解及优化
Verilog语言中case语句详解及优化 详细讲解了case语句的原理、实现。并说明了如何合理使用case从而实现程序的优化配置
SQL Server中的SQL语句优化与效率问题
很多人不知道SQL语句在SQL SERVER中是如何执行的,他们担心自己所写的SQL语句会被SQL SERVER误解。比如: select * from table1 where name=’zhangsan’ and tID > 10000 和执行: select * from table1 where tID > 10000 and name=’zhangsan’ 一些人不知道以上两条语句的执行效率是否一样,因为如果简单的从语句先后上看,这两个语句的确是不一样,如果tID是一个聚合索引,那么后一句仅仅从表的10000条以后的记录中查找就行了;而前一句则要先从全表中查找看有几个name=’z
if语句的优化
if语句的优化


