SQL JOINS

  • Koen Verbeeck (1/8/2013)


    Not sure what this question tries to teach us....

    I guess.. this; if the aliases are been removed in SELECT block, it gives below error on ambiguity for couple of column names. (some sort.... author might had in mind)

    Msg 209, Level 16, State 1, Line 3

    Ambiguous column name 'Name2'.

    Msg 209, Level 16, State 1, Line 4

    Ambiguous column name 'Name3'.

    (looks like this was one of the "out of the box" experience πŸ™‚ )

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • Koen Verbeeck (1/8/2013)


    Not sure what this question tries to teach us.

    I spend 5 minutes looking for a mistake, only to finally decide there wasn't one, all joins seemed legit. I got it right, but I suddenly was surprised the question was about table aliases.

    I'm with Koen on this one. I spent a few minutes (I think more than 5) analyzing the queries and looking for that "gotcha" that sticks out once you find it, but no such luck on that.



    Everything is awesome!

  • I concur with many here. It were somewhat of a disappointment to end up with some alias-stuff after spending quite some time looking for the column not being aggregated, or, as I thought first, some union with disparaging column definitions or some such. But no, just straight aliasing.

    I am quite used to aliasing a lot of tables, and also making sure to get the right columns from the right tables when the names clashes, sΓ₯ the alias stuff were the last thing on my mind.

    But thank you for the question anyway. A good friday question, even on a wednesday πŸ™‚

    /Keld

  • Koen Verbeeck (1/8/2013)


    Not sure what this question tries to teach us.

    I spend 5 minutes looking for a mistake, only to finally decide there wasn't one, all joins seemed legit. I got it right, but I suddenly was surprised the question was about table aliases.

    Same here... and since we went to wide short monitors I had to keep scrolling up and down to make sure I could keep the entire schema in my head.

    Koen Verbeeck (1/8/2013)


    Maybe I was more surprised that apparently the criteria for a query to run succesfully is to get your table aliases correct πŸ™‚

    Among other things πŸ™‚



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • Thanks for an easy question.

    However, I noticed then if the QotD offers choice 'this will run' and 'this will not run', in most cases the answer is 'it will', so the question is reduced to 'is there an egregious problem?'. Which takes a good deal of fun out of figuring out the correct answer.

  • Thanks for all comments. we use aliases in joins. Aliases are not for columns where there is only one column possible. But it is nice to have all aliases listed just for maintainability in joins.

    --------------------------------------
    ;-)β€œEverything has beauty, but not everyone sees it.” ― Confucius

  • sqlnaive (1/9/2013)


    Dineshbabu (1/8/2013)


    Andre Ranieri (1/8/2013)


    Nice question - I wonder if the question category should have been table aliases instead of joins πŸ™‚

    Thanks,

    Andre Ranieri

    +1

    I agree with both Andre and Dineshbabu. Was looking for any issues in the joins for couple of minutes but found no issues.

    +1

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • chgn01 (1/9/2013)


    Aliases are not for columns where there is only one column possible.

    Whyever not?

  • chgn01 (1/9/2013)


    Thanks for all comments. we use aliases in joins. Aliases are not for columns where there is only one column possible. But it is nice to have all aliases listed just for maintainability in joins.

    For my learning... how does using aliases affect maintainability?

    Thanks,

    Tom

  • Nice, had to think about it far a few minutes but got it.

    Thanks

    Not all gray hairs are Dinosaurs!

  • Revenant (1/9/2013)


    Thanks for an easy question.

    However, I noticed then if the QotD offers choice 'this will run' and 'this will not run', in most cases the answer is 'it will', so the question is reduced to 'is there an egregious problem?'. Which takes a good deal of fun out of figuring out the correct answer.

    Agreed.

    Rob Schripsema
    Propack, Inc.

  • Good question, got it! Thanks

    _______________________________________________________________
    "The best way to prepare for programming is to write programs, and
    to study great programs that other people have written." – Bill Gates

  • Thanks for the easy question. Glad I didn't second guess myself.

  • Easy one.. but good question..

    Thanks..

  • +1

Viewing 15 posts - 16 through 30 (of 33 total)

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