I have the following query:
SELECT *
FROM SERQUENCIAL
WHERE DATA BETWEEN '2017-01-01' AND '2017-01-19'
It returns:
+--------------+-------+------------+-----------------------+
| ID_PESS NOME | DATA | DATA_HORA | SEQUENCIAL |
+--------------+-------+------------+-----------------------+
| 8788 | JOAO | 2017-01-01 | 2017-01-01 13:01:01 1 |
| 8788 | JOAO | 2017-01-01 | 2017-01-01 15:07:01 2 |
| 8788 | JOAO | 2017-01-01 | 2017-01-01 17:08:01 3 |
| 8788 | JOAO | 2017-01-01 | 2017-01-01 19:03:01 4 |
| 8533 | MARIA | 2017-01-03 | 2017-01-03 11:01:01 1 |
| 8533 | MARIA | 2017-01-03 | 2017-01-03 14:07:01 2 |
| 8533 | MARIA | 2017-01-03 | 2017-01-03 16:08:01 3 |
| 8533 | MARIA | 2017-01-03 | 2017-01-03 18:03:01 4 |
| 8935 | JOSE | 2017-01-05 | 2017-01-05 13:01:01 1 |
| 8935 | JOSE | 2017-01-05 | 2017-01-05 19:07:01 2 |
| 8935 | JOSE | 2017-01-05 | 2017-01-05 20:08:01 3 |
| 8935 | JOSE | 2017-01-05 | 2017-01-05 22:03:01 4 |
| 8935 | JOSE | 2017-01-05 | 2017-01-05 23:03:01 5 |
+--------------+-------+------------+-----------------------+
How do I merge the returns per person as follows:
+---------+------+------------+---------------------+------+---------------------+------+---------------------+------+---------------------+------+
| ID_PESS | NOME | DATA | DATA_HORA_01 | SEQ1 | DATA_HORA_02 | SEQ2 | DATA_HORA_03 | SEQ3 | DATA_HORA_04 | SEQ4 |
+---------+------+------------+---------------------+------+---------------------+------+---------------------+------+---------------------+------+
| 8788 | JOAO | 2017-01-01 | 2017-01-01 13:01:01 | 1 | 2017-01-01 15:07:01 | 2 | 2017-01-01 17:08:01 | 3 | 2017-01-01 19:03:01 | 4 |
+---------+------+------------+---------------------+------+---------------------+------+---------------------+------+---------------------+------+
That is, the person's data together on the same line.
Note :
The person's data can be repeated on another day. If it happens, it will be a new line of the person.