Sql server 2008 在检索数据时,我想再添加2个冒号..可能吗?

Sql server 2008 在检索数据时,我想再添加2个冒号..可能吗?,sql-server-2008,Sql Server 2008,在这里使用第一个案例和第二个案例的结果使用Sp检索数据时,我想为此再添加两列…可能吗 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

在这里使用第一个案例和第二个案例的结果使用Sp检索数据时,我想为此再添加两列…可能吗

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

此SP的结果是什么以及您期望的结果(哪些列)?studentcode |全名|中心代码| InstorYear | Branchname | totalpayment | BalanceAmt | ClosingDebt |结果将检索所有列数据并计算ClosingDebt和ClosingDebt,但我想插入两列openAdv,使用ClosingAdv和ClosingDebt的值打开债务…
OpenAdv
使用
ClosingAdv
返回什么结果?ClosingAdv返回总付款和余额金额之和。如果总付款+余额金额为+ve,或者如果负的ClosingDebt值将在OpenDebt sirI中加总,则此值应出现在下个月的OpenAdv记录中明白了,你能用样本数据发布有问题的例子吗?