That case filter

  • bopeavy (7/21/2011)


    Ninja's_RGR'us (7/21/2011)


    Please read my full explaination in my first post of the thread.

    You must have a keyboard shortcut for this by now.;-)

    Yup it's called ctrl-c / v. :hehe:

  • :exclamationmark:

    >>>Strangely when I run this code and do a select on the table I get 8 rows.

    Yep, the code I ran was just a simple copy and paste from the QOTD and an added line at the end containing "select * from @tbl" in order to show the contents of the table.

    When I ran it yesterday (Wednesday) it came back with 8 rows.

    When I ran it today (Thursday) it came back with 5 rows.

    I now can't seem to recreate the 8 row result.

    Hmmmm... I'll try it again next Wednesday to see what happens then.

  • david.moule (7/21/2011)


    :exclamationmark:

    >>>Strangely when I run this code and do a select on the table I get 8 rows.

    Yep, the code I ran was just a simple copy and paste from the QOTD and an added line at the end containing "select * from @tbl" in order to show the contents of the table.

    When I ran it yesterday (Wednesday) it came back with 8 rows.

    When I ran it today (Thursday) it came back with 5 rows.

    I now can't seem to recreate the 8 row result.

    Hmmmm... I'll try it again next Wednesday to see what happens then.

    Tx, keep me posted.

  • I thought this was a very good question. I must admit i spent time debugging the CASE statement in my head to try and determine what it would return - before noticing the UNION ALL in front of the SELECT * and returning to the text of the question to confirm what was being asked.

    And of course, as somebody else has already point out, Rows Affected <> Rows Returned. There's only an INSERT. No SELECT, no return.

    Nice one.



    Scott Duncan

    MARCUS. Why dost thou laugh? It fits not with this hour.
    TITUS. Why, I have not another tear to shed;
    --Titus Andronicus, William Shakespeare


  • Ninja's_RGR'us (7/21/2011)


    malleswarareddy_m (7/20/2011)


    feel upset by seeing the answer.There is only insert ..select is there.So i choosed 5 answer so that 5 rows got affected.even i tried in ssms also its also showing 5 rows got affected.

    There is nothing to learn. I got fully upset.

    Affected <> RETURNED.

    Please read my full explaination in my first post of the thread.

    Ya Your are corrected.I did not think properly before answering the question.Now onwards i will read the question properly.

    Malleswarareddy
    I.T.Analyst
    MCITP(70-451)

  • malleswarareddy_m (7/22/2011)


    Now onwards i will read the question properly.

    How long I wonder before the next QotD where a literal reading of the question leads to the wrong answer, and another endless debate about whether it was obvious what the questioner really meant 😉

  • Toreador (7/22/2011)


    malleswarareddy_m (7/22/2011)


    Now onwards i will read the question properly.

    How long I wonder before the next QotD where a literal reading of the question leads to the wrong answer, and another endless debate about whether it was obvious what the questioner really meant 😉

    It used to happen every few days. Now it's getting better since Steve is taking the MCM and posting a ton of questions himself.

    That debate however has no end in sight as far as I can imagine, untill everybody takes 100% responsibility for their own life. Now that could start another very long debate ;-).

  • Ninja's_RGR'us (7/22/2011)


    That debate however has no end in sight as far as I can imagine, untill everybody takes 100% responsibility for their own life. Now that could start another very long debate ;-).

    dont go there dude, dont go there!

    😀

    Ben

    ^ Thats me!

    ----------------------------------------
    01010111011010000110000101110100 01100001 0110001101101111011011010111000001101100011001010111010001100101 01110100011010010110110101100101 011101110110000101110011011101000110010101110010
    ----------------------------------------

  • BenWard (7/22/2011)


    Ninja's_RGR'us (7/22/2011)


    That debate however has no end in sight as far as I can imagine, untill everybody takes 100% responsibility for their own life. Now that could start another very long debate ;-).

    dont go there dude, dont go there!

    😀

    I am there... and strangely enough, never been happier :Whistling:. :smooooth:

  • Yep, I got it wrong, also. But to me I got it right because I figured out it would have inserted 5 rows, as started.

  • jlennartz (7/22/2011)


    Yep, I got it wrong, also. But to me I got it right because I figured out it would have inserted 5 rows, as started.

    You beat me on that point. I stopped trying to decide between 5 and 8 when I realized it would return zero rows. Did you you see that and decide it was a slip on Ninja's part? Or did you concentrate on the case statements and let the fact that no rows are returned slip by? Either way, this QOD teaches various lessons, don't you think?

  • Toreador (7/22/2011)


    malleswarareddy_m (7/22/2011)


    Now onwards i will read the question properly.

    How long I wonder before the next QotD where a literal reading of the question leads to the wrong answer, and another endless debate about whether it was obvious what the questioner really meant 😉

    And as if by magic...

    http://qa.sqlservercentral.com/Forums/Topic1147125-1222-1.aspx

  • Toreador (7/25/2011)


    Toreador (7/22/2011)


    malleswarareddy_m (7/22/2011)


    Now onwards i will read the question properly.

    How long I wonder before the next QotD where a literal reading of the question leads to the wrong answer, and another endless debate about whether it was obvious what the questioner really meant 😉

    And as if by magic...

    http://qa.sqlservercentral.com/Forums/Topic1147125-1222-1.aspx

    Ya, now that's a typo.

    But then again it just makes the correct answer more obvious. Also note the title : "precedence". You guys can't complain about a trick question over there :hehe:.

  • I Igree

  • I had missed the fact that there was no select to return any rows. I was consentrating on what was put into the table. I tend to learn as much from the discussions of the QOTD as from the Questions themselves.

Viewing 15 posts - 166 through 180 (of 200 total)

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