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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:55:59+00:00 2026-06-12T15:55:59+00:00

Not sure how to word this. Say i have a select returing this. Name,

  • 0

Not sure how to word this. Say i have a select returing this.

Name, month, amount
John, June, 5
John, July,6
John, July, 3
John August, 10

and I want to aggregate and report beggining blance for each month.

name, month, beggining balance.

john, may, 0
john, june, 0
john, july, 5
john, august, 14
john, September, 24

I can do this in excel with cell formulas, but how can I do it in SQL without storing values somewhere? I have another table with fiscal months i can do a left outer join with so all months are reported, just not sure how to aggregate from prior months in sql.

  • 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-12T15:56:01+00:00Added an answer on June 12, 2026 at 3:56 pm
    select
    name
    , month
    , (select sum(balance) from mytable 
       where mytable.month < m.month and mytable.name = m.name) as starting_balance
    from mytable m
    group by name, month
    

    This is not as nice as windowing functions, but since they vary from database to database, you’d need to tell us which system you are using.

    And it’s an inline subquery, which is not very performant. But at least it’s easy to understand what’s going on !

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

Sidebar

Related Questions

I am not sure how to really word this, but I have a game
I am not sure whether distinct is the right word for this. I have
Not sure how to word the question concisely :). I have say 20 Posts
I'm not sure how to word this cause I am a little confused at
Not quite sure how to word this question. I am wondering if there is
I am not really sure how to word this question, so I did the
Not really too sure how to word this question, therefore if you don't particularly
I'm not 100% sure how I should word this question but I'll try my
I'm not entirely sure if this is the best way to word it, however,
I have a question but I'm not sure of the word to use. My

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.