Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to design a balance sheet

Author  Topic 

poornima
Starting Member

32 Posts

Posted - 2006-10-24 : 05:00:46
Hello

I have designed a balance sheet which works well in excel,its simple containing columns date,reason(fordebit/credit),credit,debit,balance.If i enter the credit amount it gets added to the balance,if the amount is debited,it gets subtracted from the balance.

How do design the above in SQL

Thanks In Advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-24 : 05:05:22
[code]SELECT q.SNo,
CONVERT(varchar, q.Date, 102) Date,
q.Reason,
q.Credit,
q.Debit,
(SELECT SUM(x.Credit - x.Debit) FROM MyTable x WHERE x.Date <= q.Date) Balance
FROM MyTable q[/code]

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-24 : 05:19:44
If you use Reports like Crystal Reports, you make use of formula and Running Total feature

Formula

Credit-Debit

and create Running total based on that

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -