Q:

SQL: Sort for start date if there is no end date

I created a little SQL-fiddle: http://sqlfiddle.com/#!9/1cbee/1
I would like to sort these values:
INSERT INTO ForgeRock
    (`id`, `title`, `startdate`, `enddate`)
VALUES
    (1, 'Test 1', '2015-12-01 13:30:00', '0000-00-00 00:00:00'),
    (2, 'Test 2', '2015-12-01 14:30:00', '0000-00-00 00:00:00'),
    (3, 'Test 3', '2016-01-01 10:30:00', '2016-01-01 14:30:00'),
    (4, 'Test 4', '2016-01-01 09:30:00', '2016-01-01 15:30:00');

With SQL.  The problem is: I would like to sort it according to the start date - if there is an end date, I would like to sort by end date. 
The result should be:
    (2, 'Test 2', '2015-12-01 14:30:00', '0000-00-00 00:00:00'),
    (1, 'Test 1', '2015-12-01 13:30:00', '0000-00-00 00:00:00'),
    (4, 'Test 4', '2016-01-01 09:30:00', '2016-01-01 15:30:00');
    (3, 'Test 3', '2016-01-01 10:30:00', '2016-01-01 14:30:00'),

So the first items should be shown with descending order.  All items with an end date should be displayed after (!)  the items with no end date. 
Any ideas how to solve that?  

A:

Try this:
SELECT
  title,
  startdate,
  enddate
FROM
  ForgeRock
ORDER BY 
   CASE WHEN enddate = '0000-00-00 00:00:00' THEN 0 ELSE 1 END,
   enddate DESC, 
   startdate DESC

This will display all items without an end date first, followed by all items with an end date.