本文介绍了比较一个列值与sql server中相同的数据列值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  ALTER   proc  [dbo]。[K_RT_GetRatebasedonmeat] 
@ partyname int
@ meattype int
as

开始


选择 case 何时 PE.meattype<>(选择 meattype 来自 K_RT_PartyNameYearly 其中 partyname = @ partyname)然后 0 else isnull(PE.rateperkg, 0 end as rateperkg from K_RT_PartyNameYearly PE
inner join K_RT_PartyName PN PE.partysno = PN.sno 其中 PE.partysno=@partyname PE.meattype=@meattype
end









我这样写是为了我的要求,但它不能正常工作。当我传递partyname和meattype作为参数时,如果K_RT_PartyNameYearly此表不包含那个partyname的肉类型,那么我想显示0值。我怎么写,请帮助我。

解决方案

ALTER proc [dbo].[K_RT_GetRatebasedonmeat]
@partyname int,
@meattype int
as

begin


select case when PE.meattype<>(select meattype from K_RT_PartyNameYearly where partyname=@partyname) then 0  else isnull(PE.rateperkg,0) end as rateperkg from K_RT_PartyNameYearly PE
 inner join K_RT_PartyName PN on PE.partysno=PN.sno where PE.partysno=@partyname and PE.meattype=@meattype
 end





I wrote like this for my requirement but its not working properly. When i pass partyname and meattype as parameters, If "K_RT_PartyNameYearly" this table does not contain meattype for that partyname at that time I want to show 0 value.How can i write please help me.

解决方案


这篇关于比较一个列值与sql server中相同的数据列值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 22:42