0
Good night, you guys.
I am using select below, but I would like the turns to be columns. As there is no pivot option, how can I do this?
select tma.turma as TURMAS, tno.turno as TURNOS, count (tno.turno) as QTDE
from (select * from Visita v
where
(v.dataCadastro BETWEEN (strftime(v.dataCadastro, '2021-04-01')) AND
(strftime(v.dataCadastro, '2021-05-31')))) resultado
INNER JOIN Turma tma ON (resultado.turma_id = tma.id)
INNER JOIN Turno tno ON (resultado.turno_id = tno.id)
group by TURMAS, TURNOS
For example:
I saw some solutions with CASE, but there may be other registrations of "classes" and "shifts" later, so it would not help me.
Unfortunately, CASE will not help me because the table values are not fixed. The user can register anything and as many items as he wants. So I won’t be able to use CASE.
– Thiago