select '**'=case when na2<>0 then na1/na2 else 0 end from 表名

解决方案 »

  1.   


    select case na2 when 0 then 0 else na1/na2 end as ** from 表名
      

  2.   

    select d=case na2 when 0 then na2
                      else na1/na2 
    into #temp
    from 表名
    select d as '**' from #temp
      

  3.   

    select (case na2 when 0 then 0 else na1/na2 end) as aa  from 表
      

  4.   

    select (case na2 when 0 then 0 else na1/na2 end) as NewFieldsName from 表名
      

  5.   

    Case 很好用。楼主可以学习学习这个关键字的用法。
    很多时候都会要用到的