The Lonely and Neglected Cartesian Product (Cross Join)

  • Comments posted to this topic are about the item The Lonely and Neglected Cartesian Product (Cross Join)

  • Thanks .. nice clear question about something I needed to learn ...

    Now my question to you: Is the company sponsored employee & spouse/partner formal dinner and dance, a benefit enjoyed in a bygone era?

    Not for all companies, seems that the smaller companies continue the tradition, while the larger ones neglect their employees by eliminating some of the "perks"

    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 (2/11/2013)


    Thanks .. nice clear question about something I needed to learn ...

    Now my question to you: Is the company sponsored employee & spouse/partner formal dinner and dance, a benefit enjoyed in a bygone era?

    Not for all companies, seems that the smaller companies continue the tradition, while the larger ones neglect their employees by eliminating some of the "perks"

    +1

    nice and clear options too :w00t: :-P:-D

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • Very good question.

    And way of explanation is awesome.

    Thanks & keep it up!

    Vinay ๐Ÿ™‚

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

  • Thanks for the nice question Thomas ๐Ÿ™‚

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • bitbucket-25253 (2/11/2013)


    Thanks .. nice clear question about something I needed to learn ...

    Now my question to you: Is the company sponsored employee & spouse/partner formal dinner and dance, a benefit enjoyed in a bygone era?

    Not for all companies, seems that the smaller companies continue the tradition, while the larger ones neglect their employees by eliminating some of the "perks"

    ding ding ding - +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

  • Good question and background info to something (which if carefully used) that can be very useful

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a questionThere are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. โ€• Carl Sagan I would never join a club that would allow me as a member - Groucho Marx

  • Thank you, Thomas for the question, was set nicely.

    With all the information provided and the associated non SQL section - I did not use any of my intelligence (what I have) but just counted the output columns which was 2 and then matched the same with the SQL query which was then 3rd query and yes... i made my 2 points. ๐Ÿ˜›

    First thing I did was see the meaning of this word "Cartesian" (Noun - A follower of Descartes.)

    Now I will read all the provided links.

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

  • Wow, amazing question. Are you an MCQA (Microsoft Certified QotD Architect)?

    Best Regards,

    Chris Bรผttner

  • This was removed by the editor as SPAM

  • Nice question..

    --
    Dineshbabu
    Desire to learn new things..

  • Now my question to you: Is the company sponsored employee & spouse/partner formal dinner and dance, a benefit enjoyed in a bygone era?

    "company sponsored"... does not compute??#!? I have to buy my own coffee!

    :crying:

    Thanks for the question, very educational.

  • I selected "none of these are correct".

    The first two are wrong for the reasons stated in the answer.

    The third is wrong because the requirements are that the three rows for each person are produced with a 1 on the first row, 2 on the second, and 3 on the third. There is nothing in the proposed "third query attempt" which guarantees this ordering within the rows for each individual.

    It sorts by t1.pk (and attempts to sort at a lower level by t1.column1 , although there can be no circumstances where two rows in the output have different values for t1.column1 but the same values for t1.pk, since pk is defined as the primary key)

    This guarantees that the three rows for each person are listed together, but does not sort them into any particular order. You might get the order you want, but you can't be sure.

  • Great question! I just recently started using cross joins and am seeing their beauty. This was an amazingly timed QotD for me.

    As for company parties, I believe they are going the way of VHS tapes.

  • archie flockhart (2/12/2013)


    The third is wrong because the requirements are that the three rows for each person are produced with a 1 on the first row, 2 on the second, and 3 on the third. There is nothing in the proposed "third query attempt" which guarantees this ordering within the rows for each individual.

    It sorts by t1.pk (and attempts to sort at a lower level by t1.column1 , although there can be no circumstances where two rows in the output have different values for t1.column1 but the same values for t1.pk, since pk is defined as the primary key)

    This guarantees that the three rows for each person are listed together, but does not sort them into any particular order. You might get the order you want, but you can't be sure.

    +1

    I had a guess between Query 3, and None of them. I went for Query 3, thinking that the processing of the cross join would probably do an internal Sort (or just read the data from the primary index). But on reflection I should probably have gone for the 'wrong' answer, since although this is what happens in practice, it is not guaranteed based on the SQL.

    The correct query would have

    order by t1.PK, t2.PK

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

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