Sort Order - Include Null al last

  • I selected option 2 (and only option 2) and was told I was wrong, as I needed to select option 2 & 3. However option 3 returns the results in the following order:

    EmpName DateOfLeaving

    dcd2000-08-10 00:00:00.000

    abc1999-10-10 00:00:00.000

    bcd1998-11-11 00:00:00.000

    ccdNULL

    eedNULL

    and the question stated that the solution should be:

    EmpName DateOfLeaving

    Bcd 11 Nov 1998

    Abc 10 Oct 1999

    Dcd 10 Aug 2000

    Ccd null

    Eed null

    Therefore I guess thtat the question is worng. At least I should get a point for writing this reply! 😛

    Regards,

    Phil

  • Glad to see I'm not alone in deciding immediately that answer #3 with DateOfLeaving DESC wouldn't put the dates in the right order so is definitely wrong, irrespective of where the NULLs come!

    Derek

  • Only option 2 gives result as shown in the question, but reading back the question, I get really confused if that even was what was asked.

    The question is to have list off all employees with the employees with DateOfLeaving coming last

    Doesn't this mean that employees without DateOfLeaving (the null values), should be first in the result set?!

    Guess the only good solution is to give everybody their points 😀

  • The question is to have list off all employees with the employees with DateOfLeaving coming last and all others sorted ascending order of date of leaving

    Maybe he wanted to say this?

    The question is to have list off all employees with the employees without DateOfLeaving coming last and all others sorted ascending order of date of leaving

    Anyway the two answers which they say being correct have different results, so at least one of them is wrong... #3 in my opinion is wrong and I was very surprised of it when I was told that #2 alone was not correct 😉

  • Another controversial question, where you tend to lose points though u know the answer....

  • Another controversial question, where you tend to lose points though u know the answer....

  • ...Or a badly written question with the wrong answer supplied:(

  • Sorry - you were wrong

    I was already afraid of that, seeing how the text of the question and the sample output presented contradict each other.

    Really a shame. It is a very good use of the QotD to remind people of how NULLs behave in an ORDER BY, but those good intention are thwarted by poor checking of the correctness of the question and the answers.

    Tell me - is it really too much trouble to go ahead, create a table and actually (gasp!) RUN the queries before submitting the QotD to the contribution center?

    (Edit - hmmm, seems the color tag doesn't work. Bummer)


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • According to the question as specified, the only correct answer is number 2, sorting by date desc cannot give the required result regardless of null values.

  • I to got the question "wrong". What I want to know is, when someone puts up a QoD, is there any sort of checking involved by the mods/admins, or is it just like posting in the forum, you put it up and its live. If its the later then I really think that the whole posting a QoD process should be changed so that someone can double check the answers for that QoD so that questions with the wrong answers don't appear. To me, it sort of makes the site look unprofessional with incorrect answers appearing for the questions.

  • There is only 1 correct answer, and that's the 2nd. The desc, asc answer will NOT list the employees as shown.

  • Makes me think whether I should be bothering answering these questions. There has been too many mistakes in QotD lately.


    Urbis, an urban transformation company

  • Looks like I'm not alone in thinking we need some kind of editorial review over these Q&As, eh? I know English isn't everyone's first language, so I don't mean to be insulting, but a bit of proofreading just to make sure the question is intelligible would be a good thing.

    Oh, and it would help if the correct answer was actually correct. Kinda defeats the purpose otherwise.

    -----
    a haiku...

    NULL is not zero
    NULL is not an empty string
    NULL is the unknown

  • I also chose the correct answer #2. Please give us our points back:angry::angry::angry:

  • I was a bit hesitant to answer this one as I noticed there were checkboxes instead of radio buttons, and I thought to myself, "Hmmm... there's only one right answer, but it looks like they're expecting me to pick more than one." *sigh* I agree with the above posters that there definitely should have been some sort of proofreading on this one.

Viewing 15 posts - 16 through 30 (of 138 total)

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