Click here to Skip to main content
15,878,953 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a database that I created with my basic knowledge. I want to ask whether somebody could assist with a SQL statement for a running balance. I tried several proposed SQL statements, but it seems to not work.
Pardon me if I cross the line with my request.
Regards

What I have tried:

I created a table with a budgeted amount
Then I created another table with expenses
I tried to create a query which I want to indicate the available balance.
It was not successful; from there my request for assistance.
Posted
Comments
ZurdoDev 15-May-20 13:28pm    
How can we help?
Member 14833529 15-May-20 14:42pm    
1. I have a total budget amount (for a period, eg. 3 months) under its own column and an expenditure column for all expenses. All these are in one table.
2. I have to provide a running balance in my report on how I spent the funds.
ZurdoDev 15-May-20 14:45pm    
You just repeated yourself. That does not help. If you want someone to help, it would be helpful to post what you have done, what your structure looks like, what data looks like and how you expect the data to come out.

In other words, remember that we can't see anything that you have so just telling us what you want to have happen sounds like you are asking someone to do all the work for you.
Member 14833529 15-May-20 14:53pm    
Ok. I am sorry. I did not want you to do all the work for me. That is why I explained what I tried to do....and I also looked to similar questions on the forum and tried answers provided. Thanks anyway. I will try to figure it out myself. Kindest regards.
ZurdoDev 15-May-20 14:59pm    
You missed my point. How can we possibly tell you how to find the available balance when we have no idea how you are storing your data? You have a table with budgets and a table with expenses.

So, the best we can tell you, unless you give us more info, is you need to subtract your expenses from your budget. Probably. We have no idea what you are doing.

It's kind of like calling your mechanic on the phone and stating that you want to drive your car but you can't. You have to give more info.

Thousands of people are willing to help you but you need to give enough info for anyone to do that.

1 solution

Dear MadMyche,
A copy of my query follows:

ID	Date_Transaction	Credit_Details	Company	Debit_Details	Credit_Amount	Debit_Amount	Balance
1	13-May-2020	Sales of Heifers; Agra Auction A32055057	Agra	None	$21,326.00	0	$21,326.00
2	14-May-2020		Spar Mariental	Refreshments for trip to farm	$0.00	(352)	($352.18)
3	14-May-2020		Shell Mariental	Diesel	$0.00	(500)	($500.00)
4	14-May-2020		Agra	Purchase fodder, etc	$0.00	(5,640)	($5,640.00)
5	14-May-2020		Family	Profit sharing	$0.00	(1,000)	($1,000.00)
					$21,326.00	(7,492.18)	$13,833.82
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900