日期:2014-05-18  浏览次数:20503 次

sql2000的case转if的问题
select
c.kp_branch_no   as   仓库编号,    
d.kp_branch_name   as   仓库名称,            
c.kp_item_no   as   条码,    
e.kp_item_name   as   名称,
case   c.kp_sell_way  
      when   'B '     then     -c.kp_sale_qnty  
            else   c.kp_sale_qnty   end   as   销售数量,
case   c.kp_sell_way   when   'B '     then     -c.kp_sale_money  
            else   c.kp_sale_money   end   as   销售金额,    
b.vipID   AS   会员卡号,  
b.vipName   as   会员名称,      
b.sex   as   性别,    
c.kp_oper_date   as   日期    
from     pos_jyfk_flow   a   ,   vip_info   b,   pos_xsflow   c,   jb_jgck   d,   jb_spzl   e

中间的case语句怎么转成   if   的语句

case   c.kp_sell_way  
      when   'B '     then     -c.kp_sale_qnty  
            else   c.kp_sale_qnty   end   as   销售数量,
case   c.kp_sell_way   when   'B '     then     -c.kp_sale_money  
            else   c.kp_sale_money   end   as   销售金额,    
??????????

------解决方案--------------------
這裡用case不就可以?

為什麼要用if?

這裡改不了為if的.
------解决方案--------------------
在SQL SERVER好象IF不行
------解决方案--------------------
if 不能用在SELECT 语句中
------解决方案--------------------
应该是已往不了的
------解决方案--------------------
暈倒的,又是一個從來都不結貼的。

樓主,你是不是不知道怎麼結貼?
------解决方案--------------------
case when 就相當於if
------解决方案--------------------
if 不能用在SELECT 语句中