Union and Union All

  • Comments posted to this topic are about the item Union and Union All

  • Nice to be reminded of the basics

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • bitbucket-25253 (7/7/2012)


    Nice to be reminded of the basics

    +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

  • nice one...

    Regards,
    Ravi.

  • A really easy one for my Sunday evening... but it is always good to brush up on he basics.

    Thanks, Sanjeewan!

  • Easy one to start the week.:-)

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂

  • A little bit too easy. But then again, it's Monday...

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen Verbeeck (7/9/2012)


    A little bit too easy. ...

    I don't mind. After the shenanigans of last week it's nice to have a question that really does only have one possible answer! 😀

  • This was removed by the editor as SPAM

  • Question. Answer. Sorted.

  • Nice and simple back to basics, perfect for a Monday.

    Thanks 😀

    _____________________________________________________________________
    [font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]

  • Though I was a little disappointed that it could not have been A, B, A as well, after indexgate, I did manage to get the idea fairly directly.

  • nice and easy.

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!

  • Not a bad question, and got me thinking about other possible questions, so here goes - how many rows are returned in the two following cases?

    -- Query 1

    SELECT 'A'

    UNION ALL

    SELECT 'A'

    UNION

    SELECT 'A'

    -- Query 2

    SELECT 'A'

    UNION

    SELECT 'A'

    UNION ALL

    SELECT 'A'

    Try to guess first, then use MS to verify. 😀

  • For one moment, I thought there was a catch somewhere as the question and code all looked very easy.

    It's interesting how the first part of the UNION is a derived table without an outer SELECT. I thought that would raise an error. But it seems the query processor changes the order of the UNION? (EDIT: No, it doesn't.)

    Excellent question to start the week. Thank you.

    EDIT: Nevermind. I was confused with the parenthesis. SQL Server will allow that just fine. Need more coffee.

    Best regards,

    Andre Guerreiro Neto

    Database Analyst
    http://www.softplan.com.br
    MCITPx1/MCTSx2/MCSE/MCSA

Viewing 15 posts - 1 through 15 (of 37 total)

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