I tried to find a solution to this case, and I need your help.
I have the following table:
hora data tarefa
10:00 02/01/19 A
10:00 03/01/19 B
11:00 02/01/19 C
Considering that today is 02/01/2019, when making the pivot table below:
SELECT hora
, CASE WHEN data = CURDATE()
THEN tarefa
ELSE NULL
END AS campo_1
, CASE WHEN data = DATE_ADD(CURDATE(), INTERVAL 1 DAY)
THEN tarefa
ELSE NULL
END AS campo_2
FROM tabela
WHERE data BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 2 DAY)
GROUP BY hora
, data
ORDER BY hora
I get the following output:
hora Campo_1 Campo_2
10:00 A
10:00 B
11:00 C
However, I would like to get:
hora Campo_1 Campo_2
10:00 A B
11:00 C
- IN SUM, I can not GROUP the time so that only one line with 10:00 appears, and jobs A and B on this same line, below their respective dates.
Thank you in advance for some solution.