How to solve this sql query - Bandi

Posted by Jayakumars under Sql Server on 8/23/2015 | Points: 10 | Views : 1222 | Status : [Member] [MVP] | Replies : 3
Hi
web master

I need the opening balance as the previous date value in opening balance.

I have attached images given below.

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com



Responses

Posted by: Bandi on: 8/24/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
I am not seeing any attachment files with this post......

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 8/24/2015 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi
Bandi

I try to attached not coming i post my previous post please check and solve and have your select as best answer.

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/25/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down

declare @FromDate datetime = '21-08-2015' , @ToDate datetime = '23-08-2015'
SELECT
[Date],
Payment-Receipt,
RunningTotal = Payment-Receipt + COALESCE(
(
SELECT SUM(Payment-Receipt)
FROM dbo.PaymentDet AS s
WHERE s.Date < o.Date
and Date between @FromDate and @ToDate), 0
)
,(SELECT SUM(Payment-Receipt) FROM dbo.PaymentDet WHERE date<@FromDate) OldBal
FROM dbo.PaymentDet AS o
WHERE Date between @FromDate and @ToDate
ORDER BY [Date];


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response