I have to take the rows of my table grouped by types, if they are not null, and user. Order them by time. But the grouping must be separated...
This is my table:
id | event_code | user | time |
---|---|---|---|
10 | A | 6 | 2021-10-20 09:59:00 |
9 | null | 6 | 2021-10-20 09:56:00 |
8 | null | 6 | 2021-10-20 09:54:00 |
7 | A | 6 | 2021-10-20 09:53:00 |
6 | A | 6 | 2021-10-20 09:52:00 |
5 | null | 6 | 2021-10-20 09:51:00 |
4 | null | 4 | 2021-10-20 09:50:00 |
3 | B | 6 | 2021-10-20 09:49:00 |
2 | B | 6 | 2021-10-20 09:48:00 |
1 | B | 12 | 2021-10-20 09:43:00 |
i want to get this:
id | event_code | user | time | number |
---|---|---|---|---|
10 | A | 6 | 2021-10-20 09:55:00 | 1 |
9 | null | 6 | 2021-10-20 09:54:00 | 1 |
8 | null | 6 | 2021-10-20 09:54:00 | 1 |
7,6 | A | 6 | 2021-10-20 09:53:00 | 2 |
5 | null | 6 | 2021-10-20 09:51:00 | 1 |
4 | null | 4 | 2021-10-20 09:50:00 | 1 |
3,2 | B | 6 | 2021-10-20 09:49:00 | 2 |
1 | B | 12 | 2021-10-20 09:43:00 | 1 |