That case filter

  • Ninja,

    Do I have a tendency to post untested code?

    As I said earlier I'm not perfect, but I think I have a good track record there

    I don't think I was being critical of your QOD, I actually enjoyed it. But you have to admit that there are many QOD's that have a problem whether with a typo or unintentional extra union which causes one to question the validity ofa QOD that intentionally has a issue.

    Then the people try to tear that person apart as if they never had a mistake.

    Steve Jimmo
    Sr DBA
    “If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan

  • sjimmo (7/20/2011)


    Ninja,

    Do I have a tendency to post untested code?

    As I said earlier I'm not perfect, but I think I have a good track record there

    I don't think I was being critical of your QOD, I actually enjoyed it. But you have to admit that there are many QOD's that have a problem whether with a typo or unintentional extra union which causes one to question the validity ofa QOD that intentionally has a issue.

    Then the people try to tear that person apart as if they never had a mistake.

    Sorry if I wasn't clear, I never felt attacked by your comments, nor any other actually.

    Glad you enjoyed it!

    And yes there have been a few typos in the past qotd ;-).

  • Revenant (7/20/2011)


    "How many rows returned by executing all of the following?"

    I ran "all of the following" under 2005 Enterprise and Express and under 2008 R2 Datacenter, Standard, Developer and Express and in every single case I got 5 rows.

    <rant>

    I don't believe that your installations can be that badly broken. You don't understand what your system is telling you: did you see a list of 5 rows with values in the rows? If so you got 5 rows, and 5 rows were returned. I don't believe you saw that. Or did you see no rows, no vaues, at all, just a message saying that 5 rows had been affected? If so no rows were returned. I believe that is what you saw. If you ddidn't understand that any rows returned will be listed, with their values, then if you have now learned that the question was very valuable to you. If you did understand that, but chose to ignore it because you wanted the question to mean not what it said but something completely different, then perhaps you have now learned to read the words and refrain from distorting the meaning to suit your unjustifiable preconceptions, which would also be an extremely valuable lesson.

    </rant>

    Perhaps I'm not being fair picking on revenant as the target of my rant, as there have been lots of nonsensical and/or utterly counterfactual statements in the discussion of this question (which, of course, is a natural consequence of a QoTD that requires people to discard their erroneous preconceptions to get the right answer - such questions and answers inevitably invite more flak than the ones that are just plain wrong) but I'd seen too many up to this point and built up a nice head of steam, and the claim that s/he "got" 5 rows in response to a question not about rows gotten (whatever that may mean) but in fact about rows returned just blew my safety valve.

    Sure, it's a "trick" question where the title is designed to make you look in the wrong place. SO what - that puts you in the frame of mind equoipped with misguided preconceptions that you often hit when debugging. It's a good reminder that such preconseptions are a real danger.

    Tom

  • This was a nice question.

    First I followed the line whic most of the herd seem to have selected, and thought "5".

    Then I thought "no, that's too easy - can something allow that final sekect to some of the rows inserted by earlier clauses of the union and get some more rows? And if so, which answer would be right - maybe "it depends". But then "no, not even the MS optimzer team are arrogant enough to change the semantics of SQL in such a bizarre way" (I must have been in optimistic mode ;-)).

    Next: the layout of the final select is disgraceful - nesting levels totally obscured - am I sure there's not a syntax error? Looked hard, there obviously wasn't. I've said "obviously" before and been wron, so I checked it into Management Studio and sure enough, no syntac error. And it says 5 rows affected.

    So back to "u=it's 5!. But that's too obvious, too easy. Read it again; and again; and again and.....and again. Then a flash of insight: there's no statement there that returns rows! :w00t:

    I don't think I've ever worked so long or hard for a QoTD point before. And although I've said many times that a question shows us that we must pay attention to detail, that's usually been when I've got it wrong.

    So well done for driving me half bats with a real question with a real lesson in it.

    Tom

  • Tom.Thomson (7/20/2011)


    This was a nice question.

    I don't think I've ever worked so long or hard for a QoTD point before. And although I've said many times that a question shows us that we must pay attention to detail, that's usually been when I've got it wrong.

    So well done for driving me half bats with a real question with a real lesson in it.

    Thanks for the compliment, it means a lot coming from someone with so much experience :blush:.

    P.S. Nice rant, couldn't have been so nice & polite about it myself :-).

  • At the end it will show in the execute box "5 rows inserted successfully".It will never show 0 in any place.

    So i donot think the answer give by the author is correct.

    Agree with many others where they have disagreed with the answer.

    Thanks

    Dev

  • nothing intrest in this Question. if you strictly follow the Question then the answer shoud be 0 as there is no select statements to return the records. but if you see how many records getting inserted the answer should be 5.

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

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

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

    As incredible as it might seem, I actually answer real questions to get my points! Out of 14K forum posts, I think I have 1-2 posts in there that provide actual value to the question at hand ;-).

    And answer them by providing a *lot* of value in the process...

    -Ki

  • devprasaddas 81425 (7/20/2011)


    At the end it will show in the execute box "5 rows inserted successfully".It will never show 0 in any place.

    So i donot think the answer give by the author is correct.

    Agree with many others where they have disagreed with the answer.

    Thanks

    Dev

    Insert <> RETURNED

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

  • sharath.chalamgari (7/20/2011)


    nothing intrest in this Question. if you strictly follow the Question then the answer shoud be 0 as there is no select statements to return the records. but if you see how many records getting inserted the answer should be 5.

    Inserted <> Returned.

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

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

  • Hi,

    I have gone through your explaination , Tom & sharath.I will read questions more carefully before i answer them, it can be tricky like your question.

    Thanks for giving todays lesson : "read and analyze question before you jump on your answer and explaination"

    Thanks

    Dev

  • Epic conclusion & human behavior analysis

    Here are the standings as of this morning after 941 attempts :

    "It depends" (7%) is the classic answer in sql server but it just cannot apply here. The case expression is deterministic therefore it'll never change given the same parameters.

    1 - 05% That answer is just impossible. The case statement would return 3 rows

    2 - 04% That answer is just impossible. The case statement would return 3 rows

    5 - 51% You ran the code and/or didn't understand the question and/or didn't understand the case filter

    3 - 09% Yes for the case filter but you missed the extra union all. Thanks for trying without running the code and successfully decoding the case expression.

    0 - 25% Congrats (or you ran the code because you had no idea). Since 51% of you ran the code and still managed to get it wrong I'll assume that the real amount of correct answers is closer to ±12%

    Thank you all for participating and keep your stories coming.

  • 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.;-)

    :cool:

    "There are no problems! Only solutions that have yet to be discovered!"

Viewing 15 posts - 151 through 165 (of 200 total)

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