Union and Union All

  • sanjeewan99

    Say Hey Kid

    Points: 700

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

  • Ron McCullough

    SSC Guru

    Points: 63877

    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]

  • SQLRNNR

    SSC Guru

    Points: 281243

    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

  • Ravi SQL

    SSCommitted

    Points: 1714

    nice one...

    Regards,
    Ravi.

  • Revenant

    SSC-Forever

    Points: 42467

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

    Thanks, Sanjeewan!

  • rhythmk

    SSCertifiable

    Points: 7162

    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
    🙂

  • Koen Verbeeck

    SSC Guru

    Points: 258965

    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

  • SQLPhil

    SSCarpal Tunnel

    Points: 4204

    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

  • Michael Lysons

    SSCertifiable

    Points: 6478

    Question. Answer. Sorted.

  • DugyC

    Hall of Fame

    Points: 3804

    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]

  • call.copse

    SSCoach

    Points: 17201

    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.

  • Vinay Kumar

    SSCertifiable

    Points: 6098

    nice and easy.

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

  • Duncan Pryde

    SSCertifiable

    Points: 7956

    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. 😀

  • Andre Guerreiro

    SSCertifiable

    Points: 7319

    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 38 total)

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