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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:46:14+00:00 2026-06-05T11:46:14+00:00

The following information is currently present in a database. ID — Company — Current

  • 0

The following information is currently present in a database.

ID -- Company --- Current Value ---- Date
1 -- company1 ------- 12 --------- 25th March 2010
2 -- company1 ------- 17 --------- 25th March 2011
3 -- company2 ------- 65 --------- 23rd April 2011
4 -- company1 ------- 45 --------- 25th March 2012
5 -- company2 ------- 34 --------- 23rd April 2012

Is there some way that I can calculate the field to find the value for each company’s previous year ?

ID -- Company --- Current Value --- Last Year Value ---- Date
1 -- company1 ------- 12 ---------------- 0 --------- 25th March 2010
2 -- company1 ------- 17 --------------- 12 --------- 25th March 2011
3 -- company2 ------- 65 ---------------- 0 --------- 23rd April 2011
4 -- company1 ------- 45 --------------- 17 --------- 25th March 2012
5 -- company2 ------- 34 --------------- 65 --------- 23rd April 2012

I have tried many solutions including searching this website but nothing has worked.

  • 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-05T11:46:16+00:00Added an answer on June 5, 2026 at 11:46 am

    Since your table appears to have dates one year apart exactly, it can be simply done by left joining itself.

    SELECT a.ID, 
        a.Company, 
        a.CurrentValue, 
        ISNULL(b.CurrentValue, 0) AS 'LastYearValue',
        a.Date
    FROM dbo.Table a
    LEFT JOIN dbo.Table b ON a.Company = b.Company AND b.Date = DATEADD(YEAR, -1, a.Date)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following information : Name, GPA 2010, GPA 2011 Adam, [2010, 3.4],
In my mysql database I have the following information in a page name field.
I have multiple data entries that contain the following information: id_number name1 date name2
Currently programing C# methods to retrieve the following address information: Latitude/Longitude based upon postal
Were currently working on a script that reads the current users information from out
I am currently working on a while loop that should get the following information
You are given the following information, but you may prefer to do some research
Given the following information Public Enum Request As Byte None = 0 Identity =
I have a file with the following information: dog<> cat<> cow<> bird<> tiger<> lion<>
Would it be possible to extract the following information from logs? Start up/Shut down

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.