本帖最后由 cn_a380 于 2009-08-31 20:03:58 编辑

解决方案 »

  1.   

    select a.name,
           a.bal,
           a.intst_acm,
           case 
             when a.opn_date>20090621 then a.intst_acm/(trunc(sysdate)-to_date(a.opn_date,'yyyymmdd')) 
             else a.intst_acm(trunc(sysdate)-to_date('20090621','yyyymmdd'))
           end,
           case 
             when a.opn_date>20090621 then trunc(sysdate)-to_date(a.opn_date,'yyyymmdd') 
             else trunc(sysdate)-to_date('20090621','yyyymmdd')
           end kk
     from dd_mst a除非在外面再select一层,或者如上
      

  2.   

    没有其他方法了吗,这个kk需要反复用到,如果每一次都得复制、黏贴的话,很麻烦,也容易错,sql没有其他的方法了吗
      

  3.   

    因为它本身是在第一层查询时产生的,所以不能被本层的其他列用若不想重复那就在外面嵌套一层select或者把这个列和该表的其他主键查出来组成一个结果集,其他表和它join查询。select b.id/a.kk from tablename b,(select a.id, case when ... end kk from table) a
    shere b.id = a.id
    这样