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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:04:13+00:00 2026-06-10T02:04:13+00:00

I have a couple of views that generates the following two outputs in SQL

  • 0

I have a couple of views that generates the following two outputs in SQL Server.
First one (Flats output) shows the number of flats in a particular town with Tileroofs and Brickwalls. Second one shows the same, but for houses.

What I’m trying to do is to create a final table that looks like the 3rd example where the flats and house counts are combined with the corresponding Tileroof and Brickwall combinations.

I have tried union and then grouping, but I’m really struggling to get the Flats and Houses count columns side by side. Is anyone able to help please?

Thanks

--View one
| Town | Flats | TileRoofs | Brick Wall |
-----------------------------------------
| A    | 3     | Y         | N          |
| A    | 4     | N         | Y          |
| A    | 8     | N         | N          |


--View two
| Town | Houses | TileRoofs | Brick Wall |
------------------------------------------
| A    | 1      | Y         | Y          |
| A    | 2      | Y         | N          |
| A    | 5      | N         | Y          |
| A    | 2      | N         | N          |


--Prefered output, by combining the two--

| Town | Flats | Houses | TileRoofs | Brick Wall |
--------------------------------------------------
| A    | 0     |  1     | Y         | Y          |
| A    | 3     |  2     | Y         | N          |
| A    | 4     |  5     | N         | Y          |
| A    | 8     |  2     | N         | N          |
  • 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-10T02:04:15+00:00Added an answer on June 10, 2026 at 2:04 am

    Full outer join might help here.

    select isnull(a.Town, b.Town) Town,
           isnull(a.TileRoofs, b.TileRoofs) TileRoofs,
           isnull(a.[Brick wall], b.[Brick wall]) [Brick wall],
           isnull(a.Flats, 0) Flats,
           isnull(b.Houses, 0) Houses
      from ViewOne a
      full outer join ViewTwo b
        on a.Town = b.Town
       and a.TileRoofs = b.TileRoofs
       and a.[Brick wall] = b.[Brick wall]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have couple resource DLLs that I currently load when application starts using following
I have a couple of views that I display as overlays on the main
I have a couple of Views that are used in a lot of locations.
I have a couple of modal views that have been working just fine and
I have a view model with a couple of properties that are not displaying
I have a couple of views which present data from a CoreData entity in
I have an application with many views. I want only a couple of the
I have couple of dozen pieces of data that I need to save and
I have couple of issues- the first constraint on select is loaded when reference
to those that may have read my previous question that got solved a couple

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.