Sql 一个SQL语句的优化

这是一个sql语句优化的过程。使用子查询与不使用子查询的效率对比

select sum(sl0000) from xstfxps2 where
  dhao00 in (
  select dhao00 from xstfxps1 where trunc(ywrq00)=trunc(sysdate)
  and khdm00='500000003913');
已用时间: 00: 02: 49.04

select sum(sl0000)
  from xstfxps2 a,(select dhao00 from xstfxps1 where trunc(ywrq00)=trunc(sysdate)
  and khdm00='500000003913') b
  where a.dhao00=b.dhao00;
已用时间: 00: 00: 03.05

原文地址:https://www.cnblogs.com/zhangzhifeng/p/2279228.html