create view V_T
as
select A,B,C=case when B=0 then 0 else B/A End
from 表

解决方案 »

  1.   

    create view v
    as
    select A
           ,B
           ,(case when B=0 then 0 else A/B end) as 'C'
    from 表
      

  2.   

    create table div
    ( a float,
     b float)insert into div
    select 5,2 union all
    select 3,0 union all
    select 4,2 union all
    select 3,1create view v_div
    as
    select a,b,
    case b
    when 0 then 0
    else a/b end as c
    from divselect * from v_div
    結果:
    a                         b                                                 c 
    ------------------------------- ------------------------------------------------
    5.0                   2.0                                                   2.5
    3.0                   0.0                                                   0.0
    4.0                   2.0                                                   2.0
    3.0                   1.0                                                   3.0
      

  3.   

    sorry 結果:
    a            b                c
    5.0         2.0              2.5
    3.0         0.0              0.0
    4.0         2.0              2.0
    3.0         1.0              3.0
      

  4.   

    create view v
    as
    select A
           ,B
           ,(case when B=0 then 0 else A/B end) as 'C'
    from 表