select w2_month as x,w2_week as y,x-y as z from table例子:这里我用了x  y  2个别名分别表示2个字段(number类型)  现在我想用别名进行相减  这种好像不可以,请问有什么办法可以解决吗?
实际需求:W2实际入库周 是更加一个select 语句获取的  --case when(W2实际入库周 - W2计划入库周) > 0 then '10'
            --        when(W2实际入库周- W2计划入库周) = 0 then '20'
              --       when(W2实际入库周 -W2计划入库周) < 0 then '30'
           --end as 'W2是否按期入库类型',

解决方案 »

  1.   

    select 中-nvl(国,0) from ( select sal as 中 ,comm as 国 from emp) t;测试了下,好像没问题哦
      

  2.   

    原来的是一个select语句。 
      

  3.   

    select w2_month as x,w2_week as y,x-y as z from table
    这个会被当做单独列来处理不知道这样子和需求相符合吗?hr@ORCL> create table t1 (id1 number,id2 number);Table created.hr@ORCL> insert into t1 values(1,2);1 row created.hr@ORCL> commit;Commit complete.hr@ORCL> with a as (select id1 x,id2 y,id1-id2 as z from t1)
      2      select x,y,z from a;         X          Y          Z
    ---------- ---------- ----------
             1          2         -1
      

  4.   


    select w2_configure_id.nextval,''  as 统计汇总ID,C.Ordtype as 单据统计类型, D.cartypesn 车型代码,C.Dlrorderid as 采购单主单ID,B.Subdlrorderid as 采购单子单ID,
      C.planinweek as W2计划入库周,
              (select (w2_year||lpad(w2_month,2,0)||lpad(w2_week,2,0) )
                 from w2_configure
                where A.Indate between w2_configure.w2_week_startday and w2_configure.w2_week_endday
                  and rownum = 1) as W2实际入库周,A.Indate as W2实际入库时间,
               --case when(W2实际入库周 - W2计划入库周) > 0 then '10'
                --        when(W2实际入库周- W2计划入库周) = 0 then '20'
                  --       when(W2实际入库周 -W2计划入库周) < 0 then '30'
               --end as 'W2是否按期入库类型',
               10,
               10000,
               sysdate as 操作时间,
               A.Houseinid as 入库单ID
         from t_vopr_housein_m A, t_vopr_dlrorder_d B, t_vopr_dlrorder_m C, t_vcar_car_m D
        where  A.Src_Billid = B.Subdlrorderid and B.Dlrorderid = C.Dlrorderid and B.CARID = D.CARID
      

  5.   

    这里是我完整的代码   
    W2实际入库周:
    select (w2_year||lpad(w2_month,2,0)||lpad(w2_week,2,0) )              from w2_configure             where A.Indate between w2_configure.w2_week_startday and w2_configure.w2_week_endday               and rownum = 1) as 
      

  6.   

    ????????????????????? 
    select (select a from table) as a,b,a-b as c from table1上面这种形式的 不行 不能用 a-b as c 别名不能这样用!!!
    请问有什么办法 演变下处理!!!
      

  7.   

    哪个数据库也不支持这么写,同一层的你能直接用别名引用?想最简单实现,就写成select x,y,x-y z from 
      (select w2_month x ,w2_week y  from table)