Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
DaveBF
Yak Posting Veteran
89 Posts |
Posted - 2011-11-28 : 09:44:17
|
I have a Select which returns Names, some of which are preceded by (Vacant). For example,Smith, JohnJones, Scott(Vacant) Doe, JaneI want the names to be alphabetized, except that I want all the ones preceded by (Vacant) to be at the bottom of the list.When I just say Order by Name, it alphabetizes the open paren to the top of the list. Any ideas on how to do this? If it helps, I don't care so much about the alphabetizing of the (vacant) names. I just want them all at the bottom. |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-11-28 : 10:05:15
|
SELECT Name FROM NamesORDER BY CASE WHEN Name LIKE '(Vacant)%' THEN 1 ELSE 0 END,Name |
|
|
DaveBF
Yak Posting Veteran
89 Posts |
Posted - 2011-11-28 : 10:13:59
|
Perfect. Thank you! |
|
|
|
|
|