stored procedures - compare one column values with same column values of data in sql server? -


  change proc [dbo]. [K_RT_GetRatebasedonmeat] @partyname integer, @meattype as the selection case starts int when the PE Meteciphel & lt; & Gt; (SELECT meattype FROM K_RT_PartyName YEARLY WHERE partyname = @partyname) and 0 or more (PE Reterkrk, 0) in K_RT_PartyName YEARLY PE INNER JOIN K_RT_PartyName as rate as END PN ON PE.partysno = PN.sno WHERE PE.partysno = @partyname AND PE meattype = @meattype end  

put out:

  PE.partysno PE.meattype PE.rateperkg 36 3 150 36 2 125 25 2 100  

If I pass partysno = 36 and meattype = 1 that it will show 0 that there is no data to meattype 1 to partysno because there

I Written like this for your requirement but it is not working properly when I If you pass as Aramitr partyname and meattype, K_RT_PartyNameYearly table meattype does not include that partyname at that time I want to show 0 value. How can I write this? Please help me.

Try ...

  proc changes [DBO]. [K_RT_GetRatebasedonmeat] @partysno int, click Start, such as ISE (Choose from K_RT_PartyName YEARLY WHERE partysno = @partysno and meattype = @meattype 1) Where K_RT_PartyName yuan PE BEGIN SELECT PE.partysno, PE.Myattype, PE.rateperkg PE.partysno = @partysno and PE.meattype = @meattype end of K_RT_PartyNameYearly rateperkg selected PE separate partysno partysno, null meattype, 0 start where PE.partysno = @partysno eND eND  

Comments