SQL Left join 4 tabels

  • Hello everyone.

    I am in a situation where i could use some help. I am creating a view that has to left join 3-4 tabels: a little screenshot to get the idea.

    Where there is checkmark are the colons i want to join. However to get to the 3 colons from DimKunder, i need to go though FactSystemServereKunder, since its the relation. I hope it makes sense?

    Thanks in advanced.

    Daniel

  • I'm sorry, I can't see the screenshot. It would be better if you post DDL for the tables instead of screenshots.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Nicegirl13 (11/19/2015)


    Hello everyone.

    I am in a situation where i could use some help. I am creating a view that has to left join 3-4 tabels: a little screenshot to get the idea.

    Where there is checkmark are the colons i want to join. However to get to the 3 colons from DimKunder, i need to go though FactSystemServereKunder, since its the relation. I hope it makes sense?

    Thanks in advanced.

    Daniel

    You need to use a join to get those values. Most likely from DimServere.Servernavn to FactSystemServereKunder.Servernavn. Then another join to DimKunder on FactSystemServereKunder.KundeID = DimKunder.KundeID

    That is mostly a guess though based on the column names. You might want to take a look at this article which does a great job explaining joins. http://blog.codinghorror.com/a-visual-explanation-of-sql-joins/[/url]

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply