Mysql
 sql >> Database >  >> RDS >> Mysql

Tabelle pivot PHP/MySQL

Probabilmente puoi farlo con una sottoquery e quindi produrre e aggregare questi dati. Prova qualcosa sulla falsariga di questo:

select week, 
    count(*) as total, 
    sum(technical) as technical, 
    sum(non_technical) as non_technical) 
from(
    select week, 
    case(type) when 'Technical' then 1 else 0 END as technical, 
    case(type) when 'Non-Technical' then 1 else 0 END as non_technical
) as data
GROUP BY week