I have to create a view (SQL Server 2016) where I have the sum of hours of consecutive shifts with the same ID.

The shifts can only be equal to 1 or 2 or 3; and they are in this order: 1->2->3. After shift 3 the next one is shift 1 in the next day.

A consecutive shift is where you have the same date and consecutive numbers (1->2, 2->3, 1->2->3), but also when you have consecutive dates and shift from 3 to 1 (3->1).

So I have something like this:

```
╔════╦════════════╦═════════════╦═════════════╗
║ ID ║ Date       ║ Shift       ║   Lenght    ║
╠════╬════════════╬═════════════╬═════════════╣
║ 101║ 2018-05-19 ║     2       ║      4      ║
║ 101║ 2018-05-19 ║     3       ║      16     ║
║ 101║ 2018-05-20 ║     1       ║      16     ║ 
║ 101║ 2018-05-20 ║     3       ║      14     ║
║ 202║ 2018-05-20 ║     1       ║      8      ║ 
╚════╩════════════╩═════════════╩═════════════╝

```

And I'd like to get something like that (I don't need shifts anymore):

```
╔════╦════════════╦═════════════╗
║ ID ║ Date       ║ Lenght      ║   
╠════╬════════════╬═════════════╣
║ 101║ 2018-05-19 ║ 36 (4+16+16)║      
║ 101║ 2018-05-20 ║     14      ║    
║ 202║ 2018-05-20 ║     8       ║    
╚════╩════════════╩═════════════╝

```

Can someone help me? Thanks