select a.*,
       (select sum(c.aae019)
          from ae25 b, ae23 c
         where a.aaz288 = b.aaz288
           and b.aaz083 = c.aaz083) aae019
  from ad21 a
 where 1 = 1
   and a.aae002 = 201003
   and a.aab033 = 3
   and a.aaa027 = '340122'
 order by decode(a.aae221, null, '1', '0') desc, a.aaz288 desc我的理解是:等查询出满足的条件的数据后,根据 a.aaz288 的值,再检索下面的语句,不知道可正确?
select sum(c.aae019)
          from ae25 b, ae23 c
         where a.aaz288 = b.aaz288
           and b.aaz083 = c.aaz083
 这段话什么时候执行?

解决方案 »

  1.   

    先执行from 后where 再排序 最后是选择列  所以 sum(c.aae019) 
              from ae25 b, ae23 c 
            where a.aaz288 = b.aaz288 
              and b.aaz083 = c.aaz083 这是在选择列时执行的也是标量子查询
      

  2.   

    谢谢fuyou001的帮助,原来这种做法是标量子查询啊。。哈哈
    我再想想
      

  3.   

    先执行select sum(c.aae019) 
              from ae25 b, ae23 c 
            where a.aaz288 = b.aaz288 
              and b.aaz083 = c.aaz083后select a.*,aae019 
    然后where
    最后排序