case用法

 

---select 里写case


select (case when fprice=0 then fauxprice else fprice end) fprice, * from icstockbillentry where  finterid=369383

 

 

----where 里写case

Select FName From t_AuxItem Where t_AuxItem.FItemID=v2.FAuxPropID) As FAuxPropName
From ICStockBill v1 Inner Join ICStockBillEntry v2 On v1.FInterID = v2.FInterID
Inner Join t_ICItem t1 On v2.FItemID=t1.FItemID
Inner Join t_Stock t2 On v2.FDCStockID=t2.FItemID
Inner Join t_MeasureUnit t3 On v2.FUnitID=t3.FMeasureUnitID
Left Join t_StockPlace t11 On v2.FDCSPID=t11.FSPID
Left Join t_Currency t503 On v1.FCurrencyID=t503.FCurrencyID
Left Join t_MeasureUnit t4 On t1.FSecUnitID=t4.FMeasureUnitID
  Where v1.FTranType=41
   AND t1.FNumber>= Case When @BegItemNumber='' then t1.FNumber else @BegItemNumber end
  AND t1.FNumber<= case when @EndItemNumber='' then t1.FNumber else @EndItemNumber end
  AND t2.FNumber>= case when @BegStockNumber='' then t2.FNumber else @BegStockNumber end
  AND t2.FNumber<= case when @EndStockNumber='' then t2.FNumber else @EndStockNumber end
  AND V2.FBatchNo>= case when @BegBatchNumber='' then   V2.FBatchNo else @BegBatchNumber end
  AND V2.FBatchNo<= case when @EndBatchNumber='' then V2.FBatchNo else @EndBatchNumber end
  AND v1.FDATE>= case when @BegDate ='' then v1.FDATE else  @BegDate end
  And v1.FDate<= case when @EndDate='' then   v1.FDate else  @EndDate end
And FCancelLation=0  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值