Sort Order - Include Null al last

  • It's answer is wrong!!

    Select EmpName, DateOfLeaving from Employees order by DateOfLeaving desc, EmpName asc

    This query returns descending Order of DateOfLeaving.

    It is so clear!!

    wrong answer.!!

    Hang Deok Cho.
    hyemang@gmail.com
    DBA

  • Great question. But I want my points because only the second option was correct and the explanation says that both option 2 and 3 where ok. I don't consider option 3 as a valid answer.

    Thanks, Marcos.

  • I don't think Steve is going to give us our points back. I'm not even sure if he's aware that we are all complaining about the second incorrect answer to a question in a week. As a matter of fact, both times the next day's email still had the incorrect answer in it.


    Steve Eckhart

  • Steve must be off for a couple of days. The newsletter was published today, but I didn't get it by email. The editorial was by Tony. After he sees this tirade over a trivial error, he might just quit having a QotD.

    Tom Garth
    Vertical Solutions[/url]

    "There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
  • If their reaction is that childish, then where's the professionalism associated with publishing a website of this caliber? You can't be a pro and then react to every user disappointment in your site as if you're just going to take your ball and go home. The one and only correct response is to rectify the error, add a few hundred thousand mea culpas, and move on, none the worse for wear.

    Anything less than that and now emotion is in control of the website instead of logic and reason. Right?

    Steve

    (aka smunson)

    :):):)

    Tom Garth (6/24/2008)


    Steve must be off for a couple of days. The newsletter was published today, but I didn't get it by email. The editorial was by Tony. After he sees this tirade over a trivial error, he might just quit having a QotD.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • I suppose we could probably put our subscription fees to better use.

    :smooooth:

    Tom Garth
    Vertical Solutions[/url]

    "There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
  • I another thing is that instead of complaining about wrong answers to QotD and demanding points back because the answer(s) were wrong (as in this case) or the question was poorly written (i.e. the user didn't understand it), they could just post a simple a message that indicated "Oh, I got it wrong, but it may have been I didn't understand it right" or "Oh, I got it wrong and it appears that one or more of the 'correct' answers may be wrong." and leave it at that.

    Someone talked about professionalism? How about the users showing some as well. It doesn't appear to be very professional to complain like some have here in a very public forum. Remember, it is quite easy to find people and what they have posted by just using Google.

    And to set the record straight, I am just as guilty as others having done the same on a couple of questions myself. I can say I haven't complained here, as I thought better after reading the question, the answers, and seeing that they were checkboxes instead of radio buttons. Just a slight clue that something may be a miss. I have seen a question with checkboxes that didn't have at least 2 correct responses.

    😎

  • The Suicide Hotline was busy, what's a maniac to do! I didn't get my point back, so I am suffering depression. I'll try slicing my wrists this time, maybe that'll work.:crazy:

  • U people earned more than one point by posting your fustration over the question. So why complain? 😉

  • I agree.

    Only the second option will give the desired result.

    Below is the set of results we'll get after executing all the 3 options:

    create table #temp1

    (

    EmpName nvarchar(200),

    DateOfLeaving Datetime

    )

    insert into #temp1 values('Abc', '10 Oct 1999')

    insert into #temp1 values('Bcd', '11 Nov 1998')

    insert into #temp1 values('Ccd', null)

    insert into #temp1 values('Dcd', '10 Aug 2000')

    insert into #temp1 values('Eed', null)

    Select * from #temp1

    /*

    1

    */

    Select EmpName, DateOfLeaving

    from #temp1

    order by DateOfLeaving desc, EmpName asc

    /*

    EmpNameDateOfLeaving

    Dcd2000-08-10 00:00:00.000

    Abc1999-10-10 00:00:00.000

    Bcd1998-11-11 00:00:00.000

    CcdNULL

    EedNULL

    */

    /*

    2

    */

    Select EmpName, DateOfLeaving

    from #temp1

    order by DateOfLeaving, EmpName asc

    /*

    EmpNameDateOfLeaving

    CcdNULL

    EedNULL

    Bcd1998-11-11 00:00:00.000

    Abc1999-10-10 00:00:00.000

    Dcd2000-08-10 00:00:00.000

    */

    /*

    3

    */

    Select EmpName, DateOfLeaving

    from #temp1

    order by isnull(DateOfLeaving,'10/10/9999'),EmpName asc

    /*

    EmpNameDateOfLeaving

    Bcd1998-11-11 00:00:00.000

    Abc1999-10-10 00:00:00.000

    Dcd2000-08-10 00:00:00.000

    CcdNULL

    EedNULL

    */

    Drop table #temp1

  • Anirban Paul (6/24/2008)


    U people earned more than one point by posting your fustration over the question. So why complain? 😉

    I don't understand what you mean. My posting, 2 days ago, was about the 8th complaint, and my answer is still marked as wrong. Doesn't this mean that I've yet to have my point credited? How do I earn 'more than one point' with it?

  • I also got surprised when after answering it says me U R Wrong. Then i tried the same with my own example and found I was right.

  • Correct Ans is only option #2, please see below queries. Output does not match with the desired output of question. PLEASE REMOVE "The solution should be:" FROM THE QUESTION. Such question must not be kept... THIS IS NOT FAIR...

    Create Table Employees

    (EmpName varchar(50), DateOfLeaving datetime)

    Insert into Employees values ('Abc', '10/Oct/1999')

    Insert into Employees values ('Bcd', '11/Nov/1998')

    Insert into Employees values ('Ccd', Null)

    Insert into Employees values ('Dcd', '10/Aug/2000')

    Insert into Employees values ('Eed', Null)

    select EmpName, DateOfLeaving from Employees order by IsNull(DateOfLeaving,'10/10/9999'), empName

    Select EmpName, DateOfLeaving from Employees order by DateOfLeaving desc, EmpName asc

    output of above two select statements are :

    EmpName DateOfLeaving

    Bcd 11/11/1998

    Abc 10/10/1999

    Dcd 8/10/2000

    Ccd NULL

    Eed NULL

    EmpName DateOfLeaving

    Dcd 8/10/2000

    Abc 10/10/1999

    Bcd 11/11/1998

    Ccd NULL

    Eed NULL

  • smunson (6/24/2008)


    If their reaction is that childish, then where's the professionalism associated with publishing a website of this caliber? You can't be a pro and then react to every user disappointment in your site as if you're just going to take your ball and go home.

    Please don't judge someone on what they haven't yet done - especially when there's no legitimate hint that it even will be done.

    Steve hasn't stopped the QOTD. He hasn't threatened to stop the QOTD. He has said there's a lot more work than is apparent in sanity checking a QOTD. He has said the amount of SSC's daily time that can be devoted to the QOTDs is less than is necessary to guarantee problem-free questions. He has said that if we want decent questions then more of us should step up to the mark and propose some.

    Semper in excretia, suus solum profundum variat

  • brewmanz (6/24/2008)


    Anirban Paul (6/24/2008)


    U people earned more than one point by posting your fustration over the question. So why complain? 😉

    I don't understand what you mean. My posting, 2 days ago, was about the 8th complaint, and my answer is still marked as wrong. Doesn't this mean that I've yet to have my point credited? How do I earn 'more than one point' with it?

    The QotD awards points for correct answers and you also get 1 point every time you post to the forums. Hence you've gained points by noting that the answer is wrong.

    Derek

Viewing 15 posts - 106 through 120 (of 138 total)

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