SHARE
TWEET

Untitled

a guest Feb 21st, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ...
  2. 11/09/12
  3. 12/09/12
  4. 15/09/12
  5. 08/09/12  <--here start the past dates
  6. 07/09/12
  7. 05/09/12
  8. ....
  9.    
  10. SELECT DISTINCT *,CASE  WHEN startdate < CURDATE() THEN 0
  11.                 ELSE 1 END AS past_or_future
  12.    
  13. ORDER BY past_or_future  DESC , CASE WHEN past_or_future  = 1 THEN startdate END ASC, CASE WHEN past = 0 THEN startdate END DESC
  14.    
  15. select 1 as uberkey, date1, column2
  16.   from mytable
  17.   where data1 >= '2012-10-09'
  18. union all
  19. select 2 as uberkey, date1, column2
  20.   from mytable
  21.   where data1 < '2012-10-09'
  22. order by 1 asc, 2 asc
  23.    
  24. SELECT *
  25. FROM tableName
  26. ORDER BY (CASE WHEN DATE(dateColumn) < DATE(GETDATE())
  27.               THEN 1
  28.               ELSE 0
  29.          END) DESC, dateColumn ASC
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top