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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:31:09+00:00 2026-06-18T00:31:09+00:00

I have two views on two separate servers. These views output the name, month,

  • 0

I have two views on two separate servers.

These views output the name, month, count

One view a person(Joe User) may have just July, August so it would show like this

Joe User July 19
Joe User August 28

The next view they may have some more

Joe User May 20
Joe User June 98
Joe User July 18
Joy User August 24

What I am trying to get the output to display is this.

Joe User January 0 0
Joe User February 0 0
Joe User March 0 0
Joe User April 0 0
Joe User May 20 0
Joe User June 98 0 
Joe User July 18 19
Joe User August 24 28
Joe User September 0 0
Joe User October 0 0
Joe User November 0 0
Joe User December 0 0

My question is how can I populate months even if they do not have values? Then join the values I do have.

Update:

With the examples below I get very similar results. Here is what I get when I try to run it without adding the name to WHERE.

Joe User April 65 518
Joe User April 87 518
Joe User April 52 518
Joe User April 3  518

This repeats with table values for 64 lines per month.

  • 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-18T00:31:10+00:00Added an answer on June 18, 2026 at 12:31 am
    SELECT DATENAME(mm, DATEADD(mm, number, '20010101')), 
           ISNULL(v2.[count], 0), ISNULL(v1.[count], 0)
    FROM master..spt_values v LEFT JOIN view1 v1 ON DATENAME(mm, DATEADD(mm, v.number, '20010101')) = v1.[month] AND v1.name = 'Joe User'
                              LEFT JOIN view2 v2 ON DATENAME(mm, DATEADD(mm, v.number, '20010101')) = v2.[month] AND v2.name = 'Joe User'
    WHERE v.type = 'P' AND v.number < 12
    

    Demo on SQLFiddle

    UPDATE

    SELECT *
    FROM
    (
     SELECT v1.name
     FROM view1 v1
     UNION
     SELECT v2.name
     FROM view2 v2
     ) u CROSS APPLY (
                      SELECT DATENAME(mm, DATEADD(mm, number, '20010101')) AS [month], 
                             ISNULL(v2.[count], 0) AS [count1], ISNULL(v1.[count], 0) AS [count2]                       
                      FROM master..spt_values v 
                        LEFT JOIN view1 v1 ON DATENAME(mm, DATEADD(mm, v.number, '20010101')) = v1.[month] AND v1.name = u.name
                        LEFT JOIN view2 v2 ON DATENAME(mm, DATEADD(mm, v.number, '20010101')) = v2.[month] AND v2.name = u.name
                      WHERE v.type = 'P' AND v.number < 12
                      ) o
    

    New Demo on SQLFiddle

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

Sidebar

Related Questions

I have two views, one view takes the whole screen, the second view covers
I have two views within one .xib (one view for landscape, another for portrait).
I have two separate views each containing a ScrollViewer. I want to slave one
I have a view table which is a union of two separate tables (say
I have two views, both under the NavigationController. I don't want View 1 (on
I have two views in my ViewFlipper . One of views contains a ListView
I have two views that I would like to combine into one. The first
I have two views.In first view, I have a table view and I am
I have two separate installs of WebSphere. (Actually one is WebSphere Application Server V6.1
I have two databases on separate SQL servers. They have been linked in SQL

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.