Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
Order by specific word, then alphabetically
Order by specific word, then alphabetically
Rate Topic
Display Mode
Topic Options
Author
Message
barcode-405082
barcode-405082
Posted Monday, October 19, 2009 3:57 PM
Grasshopper
Group: General Forum Members
Last Login: Thursday, November 26, 2009 1:22 PM
Points: 20,
Visits: 34
I have a lot of parameters in a table. I query the database to popuplate dropdown boxes with specific options. Some dropdowns have an option "OTHER". How do I query the database to return "OTHER" as the first option, and then sort alphabetically? eg:
Select your gender:
OTHER
MALE
FEMALE
Right now I only know how to order asc or desc or as the data was entered by ordering by the ID. Is there a way of doing what I want to do? I'm using SQL 2008 Enterprise.
Post #805311
Garadin
Garadin
Posted Monday, October 19, 2009 5:01 PM
SSCommitted
Group: General Forum Members
Last Login: Wednesday, November 07, 2012 4:08 PM
Points: 1,525,
Visits: 4,047
Something like this:
ORDER BY CASE WHEN Col='Other' THEN 1 ELSE 2 END, Col
Seth Phelabaum
Consistency is only a virtue if you're not a screwup.
Links
:
How to Post Sample Data
::
Running Totals
::
Tally Table
::
Cross Tabs/Pivots
::
String Concatenation
Post #805328
barcode-405082
barcode-405082
Posted Tuesday, October 20, 2009 9:09 AM
Grasshopper
Group: General Forum Members
Last Login: Thursday, November 26, 2009 1:22 PM
Points: 20,
Visits: 34
Thank you! Worked like a charm!
Post #805806
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.