ORDER Result

  • 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.

  • Hi,

    Please post the table script and sample data so that we can further understand your problem.

  • You can do it like this

    SELECTScheduledTime

    FROMSchedule

    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/

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply