SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sort Order - Include Null al last


Sort Order - Include Null al last

Author
Message
Manie Verster
Manie Verster
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1655 Visits: 1022
As far as I know, if you use isnull then the field, when null will take the value presented in the isnull, that means that question 2 must be right. Heck, can 98% people have it wrong. Shucks.........

:-PManie Verster
Developer
Johannesburg
South Africa

I can do all things through Christ who strengthens me. - Holy Bible
I am a man of fixed and unbending principles, the first of which is to be flexible at all times. - Everett Mckinley Dirkson (Well, I am trying. - Manie Verster)
Asim Arif
Asim Arif
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3492 Visits: 45
I made the right choice that is #2 but it says that I'm wrong??
Please correct it please.
Gianluca Sartori
Gianluca Sartori
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10146 Visits: 13351
Really funny! I've been a member since 2002 and I've never answered qod before: I answered two questions in the last ten days and both were wrong!

There's something wrong with me, maybe...

--Gianluca Sartori

How to post T-SQL questions
spaghettidba.com
@spaghettidba
Daniel van Wyk
Daniel van Wyk
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 32
I also chose option 2 and was told that it's not correct.

It seems that the "answer" is both options 2 and 3, which is incorrect. option 3 does not result in the sample output given the sample input.

According to the explanation of the answer only option 2 is correct.

This is my first time answering a question of the day, but clearly there seems to be something wrong here. What's going on with this question?
Biggles-581128
Biggles-581128
SSC Veteran
SSC Veteran (253 reputation)SSC Veteran (253 reputation)SSC Veteran (253 reputation)SSC Veteran (253 reputation)SSC Veteran (253 reputation)SSC Veteran (253 reputation)SSC Veteran (253 reputation)SSC Veteran (253 reputation)

Group: General Forum Members
Points: 253 Visits: 208
BigGrin

Seems the author fell into the trap the question was trying to highlight. Only option 2 gives the required result!!
Philip Barry
Philip Barry
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1462 Visits: 646
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
dcd 2000-08-10 00:00:00.000
abc 1999-10-10 00:00:00.000
bcd 1998-11-11 00:00:00.000
ccd NULL
eed NULL


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! Tongue

Regards,

Phil
StarNamer
StarNamer
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1694 Visits: 1992
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
Mighty
Mighty
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4448 Visits: 1705
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 BigGrin
luca.pierobon
luca.pierobon
SSC-Enthusiastic
SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)SSC-Enthusiastic (129 reputation)

Group: General Forum Members
Points: 129 Visits: 35
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 Wink
Anipaul
Anipaul
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7433 Visits: 1407
Another controversial question, where you tend to lose points though u know the answer....



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search