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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:35:53+00:00 2026-05-18T05:35:53+00:00

I have searched S.O. for this answer and have came close to an answer

  • 0

I have searched S.O. for this answer and have came close to an answer but still not close enough. I am interested in knowing if MySQL has this capability.

I have developed in Perl and MySQL 4 and I’m on MySQL 4 now.
My table looks like this…

  • symbol varchar(25)
  • todayDate date
  • interest int(11)

My problem is this…..these symbols (about 200,000 of them) update everyday with a new number for the interest field.

An example would be this….

symbol  | todayDate  | interest
-------------------------------
A202015 | 2010-10-26 | 150
A202015 | 2010-10-25 | 100

Ideally what I would be able to do would be to update another field at the end with a percentage change from the previous record. The above would then look like this….

symbol  | todayDate  | interest | change
-----------------------------------------
A202015 | 2010-10-26 | 150      | 50
A202015 | 2010-10-25 | 100

I didn’t think that this functionality was possible in MySQL. I have come to the conclusion that I just need to grab the previous record info, do the math and then update the latest record with the percentage info. I just thought I would double check and see if any MySQL geniuses had any wisdom to pass my way.

  • 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-05-18T05:35:54+00:00Added an answer on May 18, 2026 at 5:35 am

    After an email conversation with Ms. Wilkie, it turns out she wanted a percent change like this:

    update t_test_1 as t1 
        set chng = (t1.interest - (
                select interest from (
                    select *
                    from t_test_1 as t11 
                    ) as x
                where x.symbol = t1.symbol and x.todayDate < t1.todayDate 
                order by x.todayDate desc
                limit 1
                )) / 
                (
                    select interest from (
                        select *
                        from t_test_1 as t11 
                    ) as x2
                    where x2.symbol = t1.symbol and x2.todayDate < t1.todayDate 
                    order by x2.todayDate desc
                    limit 1
                ) * 100 ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched this question, and found an answer in MySQL but this is
I have searched through this forum but am not able to find an answer
I have searched the site for this simple problem but cant find an answer.
I have searched this web looking for an answer, but it seems that this
I have searched this server for the answer to this question but I haven't
I have searched this site looking for the answer and found similar things, but
I have searched this online, but I can't find the answer I am looking
I have searched around for possible answers, but did not find one that came
I have searched for this answer, but unable to find it. I am getting
I have searched lot for this answer but there is no near answer for

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.