Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 76141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:37:36+00:00 2026-05-10T20:37:36+00:00

I’m experimenting with a personal finance application, and I’m thinking about what approach to

  • 0

I’m experimenting with a personal finance application, and I’m thinking about what approach to take to update running balances when entering a transaction in an account.

Currently the way I’m using involves retrieving all records more recent than the inserted/modified one, and go one by one incrementing their running balance.

For example, given the following transactions:

t1 date = 2008-10-21, amount = 500, running balance = 1000

t2 date = 2008-10-22, amount = 300, running balance = 1300

t3 date = 2008-10-23, amount = 100, running balance = 1400 …

Now suppose I insert a transaction between t1 and t2, then t2 and all subsequent transactions would need their running balances adjusted.

Hehe, now that I wrote this question, I think I know the answer… so I’ll leave it here in case it helps someone else (or maybe there’s even a better approach?)

First, I get the running balance from the previous transaction, in this case, t1. Then I update all following transactions (which would include the new one):

UPDATE transactions SET running_balance = running_balance + <AMOUNT> WHERE date > <t1.date> 

The only issue I see is that now instead of storing only a date, I’ll have to store a time too. Although, what would happen if two transactions had the exact same date/time?

PS: I’d prefer solutions not involving propietary features, as I’m using both PostgreSQL and SQLite… Although a Postgre-only solution would be helpful too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:37:37+00:00Added an answer on May 10, 2026 at 8:37 pm

    I think this might work:

    I was using both the date and the id to order the transactions, but now I’m going to store both the date and the id on one column, and use that for ordering. So, using comparisons (like >) should always work as expected, right? (as opposed to the situation I describe earlier where two columns have the exact datetime (however unlikely that’d be).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I am currently running into a problem where an element is coming back from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.