SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ORDER BY date or value

    Hi Guys!

    I'm trying to order my results by a column called start_date. This column can either contain a value such as "Immediate" or a date such as 2012-12-01.

    Is there a way I can order my results so that all results containing "Immediate" will come up first, followed by the ones with dates (in date ascending order).

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Code:
    ORDER 
        BY CASE WHEN start_date = 'immediate' THEN 'first' ELSE 'last' END
         , start_date
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •