0
I’ve 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
Whereas today is 02/01/2019, while doing 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 SHORT, I CAN’T GROUP THE TIME TO SHOW ONLY ONE LINE AT 10:00, AND TASKS A AND B ON THIS LINE, BELOW THEIR RESPECTIVE DATES.
Thank you in advance for any solution.
You have checked whether the GROUP_CONCAT(expr) function does not meet your needs?
– anonimo
I used GRUP_CONCAT, but it returns the following output: 10:00, 10:00 A, ,B Not quite what I expected. Thanks
– Mauro Piro