I have a table with name, location, startdate and enddate as follows:
+------+----------+-----------+-----------+-----------+
| name | location | startdate | endate | is_active |
+------+----------+-----------+-----------+-----------+
| A | delhi | 3/26/2019 | 3/26/2019 | 1 |
| A | delhi | 3/27/2019 | 3/27/2019 | 1 |
| A | delhi | 3/28/2019 | 3/28/2019 | 1 |
| A | delhi | 3/31/2019 | 3/31/2019 | 1 |
+------+----------+-----------+-----------+-----------+
need to update like this:
+------+----------+-----------+-----------+-----------+
| name | location | startdate | endate | is_active |
+------+----------+-----------+-----------+-----------+
| A | delhi | 3/26/2019 | 3/28/2019 | 1 |
| A | delhi | 3/27/2019 | 3/27/2019 | 0 |
| A | delhi | 3/28/2019 | 3/28/2019 | 0 |
| A | delhi | 3/31/2019 | 3/31/2019 | 1 |
+------+----------+-----------+-----------+-----------+
If the startdate
is consecutive, the update the end date with the end date of last consecutive startdate
and also update is_active = 0
for the consecutive startdate