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

  • Home
  • SEARCH
  • 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 9106619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:22:51+00:00 2026-06-17T02:22:51+00:00

I have to find the difference in the value of a single column of

  • 0

I have to find the difference in the value of a single column of table as current row value-previous row value for some ‘n’ number of rows in one column and also I don’t have ID to use as reference for increment

date: box_count : total_no_of_boxes_used

1/12/12 2   2
2/12/12 8   6
3/12/12 14  6

I have box_count column and I am trying to get total_no_of_boxes_used column.
Please help me.

Thanks in advance

  • 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-17T02:22:52+00:00Added an answer on June 17, 2026 at 2:22 am

    Given your records are sequential by date…..

    • SQLFIDDLE DEMO

    Query:

    select a.date, a.bc, case when (a.bc-b.bc) is null then a.bc else a.bc-b.bc end tot
    from tt a
    left join 
    tt b
    on a.date > b.date
    group by b.date
    ;
    

    Results:

    DATE                            BC      TOT
    December, 01 2012 00:00:00+0000     2   2
    December, 02 2012 00:00:00+0000     8   6
    December, 03 2012 00:00:00+0000     14  6
    December, 04 2012 00:00:00+0000     23  9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When inserting a large number of rows into a single table hash cluster in
Is there anyway to find the date difference in php? I have the input
I have been trying to find out what the difference is between the IS
I have looked for similar questions, but could find none other than the difference
I have a tab delimited file of 4 columns and n number of rows.
I have been trying to find the different between MVC and 3-tier architecture in
I have different blocks of 34 threads each (0...33). I need to find a
I have seen different questions regarding this, but I still find this topic to
I have looked at the different questions regarding this issue, but couldn't find anything
I am evaluating datamining packages. I have find these two so far: RapidMiner Weka

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.