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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:48:32+00:00 2026-06-09T14:48:32+00:00

I have been going nuts over this issue for some time and I am

  • 0

I have been going nuts over this issue for some time and I am seeking help.

I have SQL Server table with values, as follows:

Account - Date - Amount - Summary 
10000 - 2010-1-1 - 50.00 - 0.00 
10000 - 2010-2-1 - 50.00 - 0.00 
10000 - 2010-3-1 - 50.00 - 0.00 
10000 - 2010-4-1 - 50.00 - 0.00 
10000 - 2010-5-1 - 50.00 - 0.00 
10000 - 2010-6-1 - 50.00 - 0.00 
10000 - 2010-7-1 - 50.00 - 0.00 
10000 - 2010-8-1 - 50.00 - 0.00 
10000 - 2010-9-1 - 50.00 - 0.00 
10000 - 2010-10-1 - 50.00 - 0.00 
10000 - 2010-11-1 - 50.00 - 0.00 
10000 - 2010-12-1 - 50.00 - 600.00 
10000 - 2011-1-1 - 25.00 - 0.00
10000 - 2011-2-1 - 25.00 - 0.00
10000 - 2011-3-1 - 50.00 - 0.00
10000 - 2011-4-1 - 50.00 - 0.00
10000 - 2011-5-1 - 50.00 - 0.00
10000 - 2011-12-1 - 25.00 - 825.00
10000 - 2012-1-1 - 100.00 - 0.00
10000 - 2012-2-1 - 200.00 - 0.00
10000 - 2012-3-1 - 100.00 - 0.00
10000 - 2012-5-1 - 100.00 - 0.00
10000 - 2012-6-1 - 100.00 - 0.00
10000 - 2012-8-1 - 100.00 - 0.00
10000 - 2012-12-1 - 100.00 - 1625.00
10001 - 2010-1-1 - 50.00 - 0.00 
10001 - 2010-2-1 - 60.00 - 0.00 
10001 - 2010-12-1 - 60.00 - 170.00 
10001 - 2011-1-1 - 50.00 - 0.00
10001 - 2011-2-1 - 50.00 - 0.00
10001 - 2011-3-1 - 50.00 - 0.00
10001 - 2011-4-1 - 50.00 - 0.00
10001 - 2011-6-1 - 50.00 - 0.00
10001 - 2011-8-1 - 50.00 - 0.00
10001 - 2011-10-1 - 50.00 - 0.00
10001 - 2011-12-1 - 50.00 - 570.00

This is a basic snapshot of the table. The “Summary” column gives the total for the “Amounts” at the end of the year (based on “date” column), but only when the MONTH(Date) = ’12’. It goes on this way for hundreds of accounts, with about 4 more years as well. I would like to add a column to this existing table, called “SummaryPreviousYear”. The SummaryPreviousYear column should have the sum of the amounts from MONTH(Date) = ’12’ and the previous year. I’d like to join this column on the account number, so that it sits next to the Summary column and gives a value just like the Summary value does, but the SummaryPreviousYear value would need to be present the whole way down the column, not just where the month is 12. For example, the following row:

Before:

Account - Date - Amount - Summary 
10001 - 2011-10-1 - 50.00 - 0.00
10001 - 2011-12-1 - 50.00 - 570.00

After:

Account - Date - Amount - Summary - SummaryPreviousYear
10001 - 2011-10-1 - 50.00 - 0.00 - 170.00
10001 - 2011-12-1 - 50.00 - 570.00 - 170.00

Can anyone help me with this? I am pulling my hair out here for 2 days and need to get this dataset created so I can proceed with my report development. Unfortunately, the DBA’s off site. Literally at my wit’s end. Any help would be greatly appreciated.

  • 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-09T14:48:33+00:00Added an answer on June 9, 2026 at 2:48 pm
    SELECT    l.*, 
              q.summary AS SummaryPreviousYear
    FROM      lists l
    LEFT JOIN 
         (
              SELECT    Date, 
                        Summary
              FROM      lists 
              WHERE     MONTH(Date) = 12
         ) AS q  
              ON YEAR(l.Date) = YEAR(q.Date) + 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been going through this weird issue on some of my virtual machines.
I have been going over tutorials but i have hit some quesitons. when the
I have been going over the practicality of some of the new parallel features
I have been going over python tutorials in this resource . Everything is pretty
I have been going over rails scheduling tasks options and stumbled upon this piece
I have been going nuts with this.. I have gnupg installed on my CentOS
I have been going crazy over this! I have an Air (2.6) app which,
I have been going through this strange issue and have no clue what's going
This is driving me nuts. I have been at it for over 2 hours
I have been going nuts trying to figure this out. I am trying to

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.