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

  • Home
  • SEARCH
  • 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 6716847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:46:56+00:00 2026-05-26T08:46:56+00:00

I have a table that looks like this: Month | Year | Rate 2011

  • 0

I have a table that looks like this:

Month   | Year  | Rate
2011    | Jan   | 50
2011    | Jun   | 55 
2011    | Nov   | 53 

Since this table I want use for financial calculation I need output in below format:

Month   | Year  | Rate
2011    | Jan   | 50
2011    | Feb   | 50
2011    | Mar   | 50
2011    | Apr   | 50
2011    | May   | 50
2011    | Jun   | 55
2011    | Jul   | 55
2011    | Aug   | 55
2011    | Sep   | 55
2011    | Oct   | 55
2011    | Nov   | 53
2011    | Dec   | 53

Any help, please

  • 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-26T08:46:57+00:00Added an answer on May 26, 2026 at 8:46 am

    The gist of the statement goes like this

    • Use an in memory table to add ID's to month names.
    • Combine this table with your original rates table to generate each month with a either an existing rate or NULL.
    • SELECT from this FullYearRates table and retrieve the non existing rates using a subselect on this table.

    SQL Script

    ;WITH months ([ID], [Month]) AS (
      SELECT 1, 'Jan'
      UNION ALL SELECT 2, 'Feb'
      UNION ALL SELECT 3, 'Mar'
      UNION ALL SELECT 4, 'Apr'
      UNION ALL SELECT 5, 'May'
      UNION ALL SELECT 6, 'Jun'
      UNION ALL SELECT 7, 'Jul'
      UNION ALL SELECT 8, 'Aug'
      UNION ALL SELECT 9, 'Sep'
      UNION ALL SELECT 10, 'Oct'
      UNION ALL SELECT 11, 'Nov'
      UNION ALL SELECT 12, 'Dec'
    )  
    , Rates ([Year], [Month], [Rate]) AS (
      SELECT 2011, 'Jan', 50
      UNION ALL SELECT 2011, 'Jun', 55 
      UNION ALL SELECT 2011, 'Nov', 53 
    )
    , FullYear ([Year], [Month], [ID]) AS (
      SELECT  DISTINCT r.[Year], m.[Month], m.Id
      FROM    Rates r
              CROSS APPLY months m
    )
    , FullYearRates ([Year], [Month], [Rate], [ID]) AS (
      SELECT  fy.[Year], fy.[Month], r.[Rate], fy.ID
      FROM    FullYear fy
              LEFT OUTER JOIN Rates r ON r.[Month] = fy.[Month] AND r.[Year] = fy.[Year]
    )
    SELECT  r1.[Year]
            , r1.[Month]
            , [Rate] = (
                SELECT  Rate 
                FROM    FullYearRates fr
                        INNER JOIN (
                          SELECT  ID = MAX(ID) 
                          FROM    FullYearRates 
                          WHERE   ID <= r1.ID 
                                  AND Rate IS NOT NULL
                        ) fm ON fm.ID = fr.ID                              
              )                    
    FROM    FullYearRates r1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that looks like this: ------------------------------------------------------------------- CUSTNUM (INT), ITEMNUM (INT), MONTH
I have a table that looks like this: Month Site Val 2009-12 Microsoft 10
I have a table that looks like this: nid vid tid 1 2 3
I have a table that looks like this: <table> <thead> <!-- random table headings
I have a table that looks like this: |StreetName NR| NR | |Teststreet 34|
I have a table that looks like this: id count 1 100 2 50
I have a table that looks like this for about ~30 students: StudentID Course*
So I have a table that looks like this: ProjectID TaskID Date 000 001
I have a table that looks something like this: word big expensive smart fast
I have an HTML table that looks like this: ------------------------------------------------- |Column 1 |Column 2

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.