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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:02:33+00:00 2026-05-30T20:02:33+00:00

I use OUTER JOIN to get values stored in rows and show them as

  • 0

I use OUTER JOIN to get values stored in rows and show them as columns. When there is no value, I show NULL in column.

Source table:

Id|Name|Value
01|ABCG|,,,,,
01|ZXCB|.....
02|GHJK|;;;;;

View:

Id|ABCG|ZXCB|GHJK
01|,,,,|....|NULL
02|NULL|NULL|;;;;

The query looks like:

SELECT DISTINCT
    b.Id,
    bABCG.Value AS "ABCG"
    bZXCB.Value AS "ZXCB"
    bGHJK.Value AS "GHJK"
FROM
    Bars b
    LEFT JOIN Bars bABCG ON b.Id = bABCG.Id and b.Name = 'ABCG'
    LEFT JOIN Bars bZXCB ON b.Id = bZXCB.Id and b.Name = 'ZXCB'
    LEFT JOIN Bars bGHJK ON b.Id = bGHJK.Id and b.Name = 'GHJK'

I want to remove LEFT JOIN because it’s not allowed in indexed view. I tried replacing it with inner SELECT, but inner SELECT is not allowed also and UNION too. I can’t use INNER JOIN because I want to show NULLs in view. What should I use?

  • 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-30T20:02:34+00:00Added an answer on May 30, 2026 at 8:02 pm

    The best you are going to be able to do is use inner joins to get the matches, then union with the left joins and filter it to only return nulls. This probably won’t solve your problem.

    I don’t know the specifics of your system but I am assuming that you are dealing with performance issues, which is why you want to use the indexed view. There are a few alternatives, but I think the following is the most appropriate.

    Since you commented this is for a DW I am going to assume that your system is more intensive on reads than writes and that data is loaded into it on a schedule by an ETL process. In this kind of high read/low write* situation I would recommend you “materialize” this view, which means when the ETL process runs, to generate the table with your initial select statement that includes the left joins. You will take the hit on the write, then all your reads will be on par with the performance of the indexed view (you would be doing the same thing the indexed view would do, except in a batch instead of on a row by row basis). If your source DB and DW are on the same instance this is a better choice than an indexed view b/c it won’t affect the performance of the source system (indexed views slow down inserts). This is the same concept as the indexed view because you take the performance hit on the insert to speed up the select.

    I’ve been down this path before and come to the following conclusion:

    An indexed view is more likely to be part of the solution than the entire solution.

    *when I said “high read/low write” above you can also think of it as “high read/scheduled write”

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

Sidebar

Related Questions

Outer joins don't seem to work whether I use a left outer join or
I have a sql-server code of cities as rows and months as columns, there
Possible Duplicate: When or why would you use a right outer join instead of
We can get the same result in both these ways.. Table_1 LEFT OUTER JOIN
We are having a debate in our company. I use left outer joins quit
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
I got a little problem. I'm using Full outer Join in Sql server -
I'm trying to get a query to compare two tables by LEFT OUTER JOINing
I am trying to figure out how to use multiple left outer joins to
why does filter for NULL in subqueries does not work? I hoped to get

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.