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

The Archive Base Latest Questions

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

How do I get a column that is the sum of the preceding values

  • 0

How do I get a column that is the sum of the preceding values of another column?

  • 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-21T05:53:14+00:00Added an answer on May 21, 2026 at 5:53 am

    You can do it by joining the table with itself (performing a so-called Cartesian or cross join). See the following example.

    SELECT a.name, a.gdppc, SUM(b.gdppc)
    FROM gdppc AS a, gdppc AS b WHERE b.gdppc <= a.gdppc 
    GROUP BY b.id ORDER BY a.gdppc;
    

    Given a table containing countries and their per capita GDP it will give you a running total of the GDP figure.

    Democratic Republic of Congo|329.645|329.645
    Zimbabwe|370.465|700.11
    Liberia|385.417|1085.527
    Burundi|399.657|1485.184
    Eritrea|678.954|2164.138
    Niger|711.877|2876.015
    Central African Republic|743.945|3619.96
    Sierra Leone|781.594|4401.554
    Togo|833.803|5235.357
    Malawi|867.063|6102.42
    Mozambique|932.511|7034.931
    ...
    

    Note that this can be a very resource-intensive operation, because if a table has N elements it will create a temporary table with N*N elements. I would not perform it on a large table.

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

Sidebar

Related Questions

when selecting a column that can contains a NULL value I get an exception
I want to insert into my table a column named 'S' that will get
I need to Sum values in a column of a list of objects joined
I have figured out that I can use hibernate to get the sum of
I need to get a sum for all items in a column within a
How to get the sum of Doubles that where parsed from a JTable ?
I am using the following line to get a column sum: columns.Bound(item => item.McGross).Width(50).Title(Amount).Aggregate(aggreages
I want to get the sum of applicants that applied to a specific position,
I need to sum of grid column. but I don't know how to get
Is there a way to get the columns that a SQL query would return

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.