How many rows are returned from the query below?

  • Lynn Pettis (3/3/2010)


    How about we put so much detail in the question that there is one and only one correct answer?

    Surely that is the point of QotD?? :hehe:

  • antony-688446 (3/3/2010)


    ...

    If this was on a MS or Sun exam, the answer would be error...

    I have seen Microsoft questions with just as much detail as this. Assumptions still had to be made in order to get the correct answer.

    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

  • I agree that with the assumptions that the table exists, it has at least 2 records and the code is ran on SQL Server 2005 or later, then the only correct answer is that the query will return 2 records. I also agree that those assumptions are logical assumptions, but I still think that the question was not a good one. If I'll modify the question and ask to select all possible answers, you'll agree with me that more then one of the possible answers that we were given will be selected. That means that every answer that would have been selected in my Imaginary modified question should be also considered as the correct answer in the real question.

    Unlike what other posters wrote, I don't think that the question should include so many details (for example that the table exists and how many records are in the table). Instead the question could have 4 possible answers that 3 of them would be wrong no matter what assumptions were used by anyone who is trying to solve the question (or if you modify the question to select all possible answers, you'd still be left with 1 answer only).

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • antony-688446 (3/3/2010)


    Lynn Pettis (3/3/2010)


    How about we put so much detail in the question that there is one and only one correct answer?

    Surely that is the point of QotD?? :hehe:

    No, the point of QotD is to make you think. It is awarded points, which people obviously covet, but if it makes you think, right or wrong as you feel the question was, it succeeded.

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."

  • antony-688446 (3/3/2010)


    Agree that QOTD is supposed to be fun & educational, and not taken seriously, but should also be clear & unambiguous. After all, assumption is the Mother & Father of all stuff ups. Why test peoples assumptions? Why not just add one line 'Assume tbleUsers exists, and has multiple rows'? Would then save 6 pages of discussion 🙂

    Yes, it would have been simple to add that line, but it was not there and that happens. Some people were able to make the assumptions and get it right, others were not.

    But the thing people have missed in the last six pages is that it is a simple QOtD and there is no reason to get so angry over missing the question becasue they made the wrong assumptions.

  • What a terrible question! We don't know whether there are any rows in tblUsers, so we don't know whether any rows will be returned or not. If there are any rows, we don't know how many so we don't know whether one row will be returned or two.

    We can guess that the intention is to ask about the case where there is at least two row in tblUsers, so that two rows will be returned. We know that in this case the second bunch of columns will have the same values in each of the two rows. But maybe there is only one row in tblUsers, in which case only one row will be returned. And maybe there are no rows in tblUsers in which case no rows will be returned.

    The obvious way to bet is that the person writing the question has just assumed that there will be enough rows in tblUsers to generate two rows of output. Lots of people who don't even notice that there's a problem with the question will answer that way, and get it right. Lots more will complain about the question (that includes me, obviously) and rightly so.

    Tom

  • Adi Cohn-120898 (3/3/2010)


    If I'll modify the question and ask to select all possible answers, you'll agree with me that more then one of the possible answers that we were given will be selected. That means that every answer that would have been selected in my Imaginary modified question should be also considered as the correct answer in the real question.Adi

    I think that modification would make it a much better question, especially if a couple more wrong alternatives were added (like 1 row plus an error message, maybe a couple of different suggested error messages,...)

    Tom

  • JF1081 (3/4/2010)


    antony-688446 (3/3/2010)


    Agree that QOTD is supposed to be fun & educational, and not taken seriously, but should also be clear & unambiguous. After all, assumption is the Mother & Father of all stuff ups. Why test peoples assumptions? Why not just add one line 'Assume tbleUsers exists, and has multiple rows'? Would then save 6 pages of discussion 🙂

    Yes, it would have been simple to add that line, but it was not there and that happens. Some people were able to make the assumptions and get it right, others were not.

    But the thing people have missed in the last six pages is that it is a simple QOtD and there is no reason to get so angry over missing the question becasue they made the wrong assumptions.

    Whose getting angry? Certainly not me! Just amazed how strongly some people will defend what is obviously a poorly worded question. Yes, it's created lots of discussion, but mostly for the wrong reasons - not much about the SQL! 'The Defenders' should realise that most people saying that the question is poor are not bitter about losing the point (I couldn't care less), are not making an attack on SQLServerCentral (Ok, one poster was, but he was way out of line!), but are (hopefully!) offering constructive criticism on how to improve future questions.

  • gaggghhhh... Seven pages of "discussion" and hardly any comments about the core learning opportunity. Did anyone besides me appreciate the mix of a new SQL feature (the CTE) and the old join syntax? I posted earlier and will repeat that I'm so used to using the JOIN keyword that I had to look twice and scratch my head a couple of times over this one. Try composing and submitting a QOD yourself if you think you can. (Yes, I have done that).

    If anyone's truly upset over the "loss" of a couple of SSC points, I hereby award each of them one thousand super-Ewok points, good at any food or drink establishment on Kandahar.

    ===========

    edit: And now I see Antony's post from a few minutes before I committed my note. Good to see at least one objector with perspective.

  • I find it ironic that the people who assumed the user table existed and had more than two rows are the same people who assume that people are bitter about losing a point.

  • john.arnott (3/4/2010)


    gaggghhhh... Seven pages of "discussion" and hardly any comments about the core learning opportunity. Did anyone besides me appreciate the mix of a new SQL feature (the CTE) and the old join syntax? I posted earlier and will repeat that I'm so used to using the JOIN keyword that I had to look twice and scratch my head a couple of times over this one. Try composing and submitting a QOD yourself if you think you can. (Yes, I have done that).

    If anyone's truly upset over the "loss" of a couple of SSC points, I hereby award each of them one thousand super-Ewok points, good at any food or drink establishment on Kandahar.

    ===========

    edit: And now I see Antony's post from a few minutes before I committed my note. Good to see at least one objector with perspective.

    I think there are a few who appreciate the question.

    If we didn't object to the question, can we still have Ewok points?

    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

  • And with a tiny bit more care in the preparation of the question, there would have been a lot more people appreciating it.

  • Fatal Exception Error (3/4/2010)


    I find it ironic that the people who assumed the user table existed and had more than two rows are the same people who assume that people are bitter about losing a point.

    Assumption?

    I demand my point. And I also demand, yet again, that standards are improved regarding the quality of these questions, and the background information to be supplied before they should be run.

    The reason I say people are angry with the points is because it seems like we have these same issues every few questions - I have seen posts on other questions asking for points for incorrect answers.

    I know very little about SQL and would like to learn more. Most of my answers are guesses but only because I have to select something to get to the discussion about the question. And I would not mind if people added posts about assumptions that could lead to wrong answers, it is just the way they do it. In fact, I learned that this would not work on SQL 2000 no matter how many rows in tblUsers - that is useful. But when they post that they got the question wrong and the error message states that it failed because the table does not exist, is that necessary? No kidding a query will fail if a table does not exist.

    ---------------

    Edit: Can I have some Ewok points even though I do not deserve them because I am helping to drag this thread out?

  • The question was worth two points.

    How many people only respond in the forum to the question, unless they get it wrong?

    When they respond because they got it wrong, they are getting their points back anyway. If they respond multiple times, then they got more points than if they normally would have.

    Edit: reworded

    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

  • Chris Houghton (3/3/2010)


    The complete results from the tblusers (lets assume 2 x users) are cross joined against the results from the CTE (which only selects 1 row from tblusers using top 1) you therefore get 2 x rows returned from the tblusers (using my assumption) each joined with the 1 row selected from the CTE - Users table.

    Therefore the 1st two columns (tblusers) return unique results by row whereas the second two colums (users CTE) return the same results twice by row.

    1chris1chris

    2jon1chris

    Hope this makes sense.

    Ah - got it. The phrasing messed me up. For some reason I thought it was saying that the two rows returned would be exactly identical, which wasn't the case. Thanks for straightening me out.

    BTW - I thought of a few more assumptions that should have been included:

    --Assume you are in the database containing tblUsers

    --Assume you have been granted rights to select from tblUsers

    --Assume the server has available memory

    --Assume there is "sufficient" (whatever that means) disk space on the drive containing tempdb

    --Assume the server room has available power (line or generator)

    --Assume the server is plugged in

    --Assume the server is on

    --Assume the hippo is asleep

    Ok, maybe not the last one, but it's good to check anyway before storming the tent. 😀

    I quit writing QODs because I couldn't come up with all the assumptions. I'm glad that others persist.

    Chad

Viewing 15 posts - 61 through 75 (of 110 total)

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