1
I have the following situation:
I have the following fiddle, with people’s license plates and registration marks.
http://www.sqlfiddle.com/#! 15/1405c/20
I tried to make that second fiddle:
http://www.sqlfiddle.com/#! 15/1405c/17
But you’re not getting the right journey start values. And I can’t get to the end of the journey either.
I needed to return something like this:
| | | | | |inicio |fim |
| matr | nome |dia | inicio | fim |turno |turno |
|------|--------------------|----|---------------------|---------------------|-------|-------|
| 1646 | VINICIUS D | 17 | 2019-01-17 08:23:21 | 2019-01-17 19:36:39 | 08:00 | 18:00 |
| 1646 | VINICIUS D | 18 | 2019-01-18 08:45:01 | 2019-01-18 19:34:48 | 08:00 | 18:00 |
| 9076 | ANTUERPIO C | 16 | 2019-01-16 05:53:51 | 2019-01-16 05:53:59 | 07:00 | 17:00 |
| 9076 | ANTUERPIO C | 17 | 2019-01-17 07:45:25 | 2019-01-17 07:45:33 | 07:00 | 17:00 |
| 9076 | ANTUERPIO C | 18 | 2019-01-18 05:51:35 | 2019-01-18 17:54:49 | 07:00 | 17:00 |
| 9076 | ANTUERPIO C | 19 | 2019-01-19 07:16:05 | 2019-01-19 07:16:08 | 07:00 | 17:00 |
| 1786 | FABIO C | 17 | 2019-01-17 18:56:21 | 2019-01-18 05:01:27 | 19:00 | 05:00 |
| 777 | CARLOS A | 17 | 2019-01-17 20:01:46 | 2019-01-17 20:01:46 | 20:00 | 06:00 |
| 777 | CARLOS A | 18 | 2019-01-18 19:50:22 | 2019-01-18 19:50:22 | 20:00 | 06:00 |
Ps: The column day, start turn and end turn are only indicative for understanding, it is not necessary to return them.