dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: SQL
Expertise: Intermediate
Sep 9, 2003

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Sorting SQL Results in Your Own Preferred Order


USE PubS
-- Sort Each of PubName in Natural Alphabetic Order but push A's to the
last
select * from publishers
Order by (CASE left(Pub_name,1) WHEN 'A' THEN 1000 ELSE ASCII(pub_name)
END)


--Sort Publishers By City in your own Order of Preference first and in a
natural order for the
--remaining cities. Also remaning cities to be sorted in the reverse alpha
order
select * from publishers
Order by (CASE City
WHEN 'Paris' 	THEN 1
WHEN 'Chicago' 	THEN 2
WHEN 'Boston' 	THEN 3
WHEN 'New York' THEN 4
WHEN 'Berkeley' THEN 5
WHEN 'Dallas' 	THEN 6
ELSE 100 END) ASC,City DESC
Kapil Srivastava
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date