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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:12:31+00:00 2026-06-09T05:12:31+00:00

I’ve got a mysql table that has a running total: +———————+——–+ | Timestamp |

  • 0

I’ve got a mysql table that has a running total:

+---------------------+--------+
| Timestamp           | Total  |
+---------------------+--------+
| 2012-07-04 05:35:00 |  1.280 | 1.280-1.280 = 0
| 2012-07-04 09:25:00 |  2.173 | 2.173-1.280 = 0.893
| 2012-07-04 09:30:00 |  2.219 | 2.219-1.280 = 0.939
| 2012-07-04 15:00:00 |  7.778 | 7.778-1.280 = 6.498
| 2012-07-04 21:05:00 | 13.032 | 13.032-1.280 = 11.752
| 2012-07-04 22:00:00 | 13.033 | 13.033-1.280 = 11.753
| 2012-07-05 05:20:00 | 13.033 | 13.033-13.033 = 0
| 2012-07-05 07:10:00 | 13.140 | 13.140-13.033 = 0.107
| 2012-07-05 10:15:00 | 14.993 | 14.993-13.033 = 1.960
| 2012-07-05 11:35:00 | 16.870 | 16.870-13.033 = 3.837
+---------------------+--------+

What I’m looking for is a query that determines the aggregated daily increase for each interval.
I’ve tried to show the desired outcome as well as the calculation behind each row. I’ve tried already several things with a join, but somehow I fail to determine what the starting value for each day is.

Thanks.

  • 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-09T05:12:33+00:00Added an answer on June 9, 2026 at 5:12 am

    I can’t vouch for the efficiency of this query, but it does get you the results you are looking for:

    SELECT t1.`Timestamp`, t1.`Total`, 
          CASE WHEN t1.`timestamp` =
                (SELECT MIN(t2.`Timestamp`)
                 FROM myTable t2 
                 WHERE DATE(t2.`Timestamp`)=DATE(t1.`Timestamp`)) 
            THEN 0
            ELSE t1.`Total` - (SELECT MIN(t3.`Total`)
                  FROM myTable t3
                  WHERE DATE(t3.`Timestamp`)=DATE(t1.`Timestamp`))         
            END AS Diff
    FROM myTable t1
    ORDER BY `Timestamp`
    

    Alternate Solution (more efficient I think)

    SELECT  t1.`Timestamp`, t1.`Total`, (t1.`Total` - d1.MinVal) diff
    FROM myTable t1 
      INNER JOIN 
         (SELECT DATE(`Timestamp`) ts_date,
                 MIN(`Total`) AS MinVal
          FROM myTable
          GROUP BY ts_date) d1
      ON DATE(t1.`Timestamp`) = d1.ts_date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a

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.