在检索数据的同时,我想再添加2列......可能吗?

时间:2014-03-17 06:33:51

标签: sql-server-2008

在这里使用Sp检索数据时使用第一种情况和第二种情况的结果我想为此增加2列...是否可能???

alter proc spAccumlated1   @InstOrYear nvarchar(10)=null, @CentreCode  nvarchar(10)=null

as
begin
SELECT a.StudentCode,c.FullName,a.CentreCode,a.InstOrYear,d.BranchName,b.TotalPayment,a.BalanceAmt,

CASE 
         WHEN (b.TotalPayment > a.BalanceAmt) THEN (b.TotalPayment - a.BalanceAmt) 
         WHEN (b.TotalPayment = a.BalanceAmt) then '0'
         else '0'

END as ClosingAdv,
CASE 
         WHEN (a.BalanceAmt > b.TotalPayment) THEN (a.BalanceAmt - b.TotalPayment)
         WHEN (b.TotalPayment = a.BalanceAmt) then '0'
         else '0'
END as ClosingDebt

from StudentFees a
left  join PDF_Students c on c.Code = a.StudentCode 
left join CollectionPaymentDetails b on b.StudentCode = a.StudentCode
left join PDF_Branch d on d.code = a.CentreCode 
left join CollectionPayment e on e.CentreCode = b.CentreCode where a.InstOrYear=@InstOrYear and a.CentreCode=@CentreCode  --and a.instoryear=@SQL  --and @onemonth=@month 
END

0 个答案:

没有答案