首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql2000的case转if的有关问题

2012-02-08 
sql2000的case转if的问题selectc.kp_branch_noas仓库编号,d.kp_branch_nameas仓库名称,c.kp_item_noas条码

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 语句中

热点排行