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 8437397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:25:01+00:00 2026-06-10T07:25:01+00:00

Im using mysql and This is the entry I have in my current table.

  • 0

Im using mysql and This is the entry I have in my current table.

So here previous balance for current month should be the remaining balance of previous month. How do I get this value from previous row of database.

Previous_balance Remaining_Balance
        0.00        42.64
        0.00        627.69
        0.00        45.54
        0.00        67.60

The result should be

Previous_balance Remaining_Balance
        0.00        42.64
        42.64       627.69
        627.69      45.54
        45.54       67.60

I have ID as PK and I want store the new previous_balance in database and print on form. So I can calculate Monthly charges and usage and other stuff. Thanks for answers.

  • 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. Editorial Team
    Editorial Team
    2026-06-10T07:25:02+00:00Added an answer on June 10, 2026 at 7:25 am

    On the assumption that the id field is ordered, try this:

    UPDATE Balances 
      SET b1.Previous_balance = COALESCE((SELECT b2.Remaining_Balance 
                                          FROM Balances b2 
                                          WHERE b2.id < b1.id 
                                          ORDER BY b2.id DESC 
                                          LIMIT 1),0) 
    FROM Balances b1
    

    I don’t have an installation of mySQL, so I can’t vouch for all the syntax. I know the SELECT statement works though.

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

Sidebar

Related Questions

I'm using MySQL. This is table i have Level Programmingtime Clientname projectid 0 128
This is a winform and I'm using mysql as a database, here is my
I'm using MySQL with PHP. This is like my table: (I'm using 3 values,
I easily get Week Number using MySql Week function like this WEEK(SYSDATE()) I just
I'm using MySQL 5, and I need to do this sentence to get the
I am using MySQL. I have several lookups like this: SELECT * from users
My table looks like this (and I'm using MySQL): m_id | v_id | timestamp
I am using mysql and I have a table with columns: postid, userid, datestamp
I am using mysql 5.0.51b. I have one table named xyz. xyz table has
Using MySQL, when I have a table with (for example) three keys (one primary,

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.