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

How to get average of a column in terms of another column and put
Anyone knows how to get sum of number? For example i have mysql column
I have table with a column that contains multiple values separated by comma (,)
I would like to get a sum from a column, with and without a
I need to get a sum for all items in a column within a
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 a list of result sets and columns that i can
I need to query the database to get the column names , not to
Given a columns' index, how can you get an Excel column name? The problem
I am looking to get a list of the column names returned from 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.