Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

ORDER Result Expand / Collapse
Author
Message
Posted Thursday, August 12, 2010 3:06 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, May 22, 2013 5:26 AM
Points: 29, Visits: 105
Hi All,
Here is my simple query,

Select ScheduledTime from Schedule
ORDER by ScheduledTime Desc

The Result i need is something like this,

Morning
Morning
Morning
Morning
Morning
Morning
Afternoon
Afternoon
Afternoon
Evening
Evening
Evening
Evening

Is there any other way to order the result without using Asc or Desc.
Post #968012
Posted Thursday, August 12, 2010 3:15 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 7:34 AM
Points: 2,819, Visits: 204
Hi,

Please post the table script and sample data so that we can further understand your problem.
Post #968015
Posted Thursday, August 12, 2010 3:41 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, October 9, 2014 7:34 AM
Points: 2,666, Visits: 4,736
You can do it like this

SELECT	ScheduledTime
FROM Schedule
ORDER BY CASE ScheduledTime
WHEN 'Morning' THEN 1
WHEN 'Afternoon' THEN 2
WHEN 'Evening' THEN 3
END




Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #968032
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse