title: Finding longest sequence in SQL
body: <p>If I have a table which contains dates, eg (in year-month-day then time format):</p>
  
  <pre><code>2015-06-22 12:39:11.257
  2015-06-22 15:44:46.790
  2015-06-22 15:48:50.583
  2015-06-23 08:25:50.060
  2015-07-01 07:11:37.037
  2015-07-07 13:40:11.997
  2015-07-08 13:12:08.723
  2015-07-08 13:12:13.900
  2015-07-08 13:12:16.010
  2015-07-10 12:29:59.777
  2015-07-13 15:42:49.077
  2015-07-13 15:47:48.670
  2015-07-13 15:47:51.547
  2015-07-14 08:11:53.023
  2015-07-14 08:14:21.243
  2015-07-14 08:16:49.410
  2015-07-14 08:17:11.997
  2015-07-14 09:58:28.840
  2015-07-14 09:59:34.640
  2015-07-15 15:39:39.993
  2015-07-17 08:45:20.157
  2015-07-24 14:00:00.487
  2015-07-24 14:03:53.773
  2015-07-24 14:12:41.717
  2015-07-24 14:13:33.957
  2015-07-24 14:15:40.953
  2015-08-25 12:43:03.920
  </code></pre>
  
  <p>... is there a way (in SQL) that I can find the longest unbroken sequence of days.  I just need the total number of days. So in the above, there are entries for 22nd June and 23rd of June, so the sequence there is 2 days. There's also entries for 13th July, 14th July, and 15th July; this is the longest sequence - 3 days. I don't care about the time portion, so an entry just before midnight, then an entry just after would count as 2 days.</p>
  
  <p>So I want some SQL that can look at the table, and return the value 3 for the above.</p>