title: DISTINCT ON combined with ORDER BY returns wrong results
body: <pre><code>results = Tracking.query. \
      filter(Tracking.time &gt;= datetime.strptime(date_1, '%d-%m-%Y'),).\
      filter(Tracking.time &lt;= datetime.strptime(date_2, '%d-%m-%Y')).\
      order_by(Tracking.device_id, desc(func.date(Tracking.time))). \
      distinct(Tracking.device_id, func.date(Tracking.time))
  </code></pre>
  
  <p>I have query like above, but resulting the only true result in the early date like this</p>
  
  <pre><code>[
      {
          "device_id": 1,
          "device_serial_number": "213123",
          "id": 31419,
          "latitude": "-6.1486514",
          "longitude": "106.894557",
          "time": "Mon, 19 Mar 2018 14:35:20 GMT",
          "video_id": 1,
          "video_name": "dubstep",
          "video_path": "http://localhost:5000/public/files/DubstepBirdOriginal5SecVideo.mp4"
      },
      {
          "device_id": 1,
          "device_serial_number": "213123",
          "id": 13000,
          "latitude": "-6.1509214",
          "longitude": "106.89634459999999",
          "time": "Sat, 17 Mar 2018 00:00:05 GMT",
          "video_id": 1,
          "video_name": "dubstep",
          "video_path": "http://localhost:5000/public/files/DubstepBirdOriginal5SecVideo.mp4"
      },
      {
          "device_id": 1,
          "device_serial_number": "213123",
          "id": 12988,
          "latitude": "-6.151098",
          "longitude": "106.89603483333333",
          "time": "Fri, 16 Mar 2018 23:59:43 GMT",
          "video_id": 1,
          "video_name": "dubstep",
          "video_path": "http://localhost:5000/public/files/DubstepBirdOriginal5SecVideo.mp4"
      }
  ]
  </code></pre>
  
  <p>16 Mar has the correct result, but others do not, as you can see in the image below: 17 and 19 of March have later data that must be shown.</p>
  
  <p><a href="https://i.stack.imgur.com/oi3Z7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oi3Z7.png" alt="enter image description here"></a></p>
  
  <p>If my query is wrong, how can I fix this query?
  I try with order by and group by and it same result.</p>