title: SQL count consecutive days
body: <p>This is the SQL database data:</p>
  
  <pre><code>UserTable
  
  UserName    | UserDate      | UserCode
  -------------------------------------------
  user1       | 08-31-2014    | 232
  user1       | 09-01-2014    | 232
  user1       | 09-02-2014    | 0
  user1       | 09-03-2014    | 121
  user1       | 09-08-2014    | 122
  user1       | 09-09-2014    | 0
  user1       | 09-10-2014    | 144
  user1       | 09-11-2014    | 166
  user2       | 09-01-2014    | 177
  user2       | 09-04-2014    | 188
  user2       | 09-05-2014    | 199
  user2       | 09-06-2014    | 0
  user2       | 09-07-2014    | 155
  </code></pre>
  
  <p>Should only count consecutive days (as Result) if [UserCode] is something else than zero.
  UserDate is between 09-01-2014 and 09-11-2014.
  Show result only if Result is 2 or more.</p>
  
  <p>What I want to my sql query to return is:</p>
  
  <pre><code>UserName    | StartDate     | EndDate       | Result
  ----------------------------------------------------------
  user1       | 09-01-2014    | 09-03-2014    | 2
  user1       | 09-08-2014    | 09-11-2014    | 3
  user2       | 09-04-2014    | 09-07-2014    | 3
  </code></pre>
  
  <p>Is this possible using only SQL query?</p>