Aseem Bhardwaj

Aseem Bhardwaj

  • 1.6k
  • 114
  • 20.6k

broad forward for getting total till current date

Oct 29 2016 7:38 AM
hi,
here is my stored procedure... give me solution for amendment for broadforward method:-
create procedure sp_broadForward
(
@gl_acid int,
@userid int,
@dateFrom datetime,
@dateTo datetime
)
as
begin
SELECT ROW_NUMBER() OVER (Order by gLedeger.PK_id) as sno,gLedeger.gl_date as date,gLedeger.gl_narration as Narration ,
case when gLedeger.gl_drcr > 0 then abs(gLedeger.gl_drcr) else 0.00 end as debit,
case when gLedeger.GL_DRCR < 0 then abs(gLedeger.gl_drcr) else 0.00 end as credit,
SUM(gLedeger.gl_drcr) OVER(ORDER BY gledeger.pk_ID ROWS UNBOUNDED PRECEDING) AS Balance
FROM gLedeger LEFT JOIN master ON
gLedeger.gl_acid = master.PK_ID left join registration r on master.userId= @userid
WHERE gLedeger.gl_acid = @gl_acid
and gl_date between Convert(Date, @dateFrom ,103) and Convert(Date,@dateTo,103)
ORDER BY gLedeger.gl_date
end

Answers (4)