I made the code below, and I would need to group by client, and I have week1, week2, week3, week4, and week5 but the information is on the same line, but this query is on separate lines separated by weeks. / p>
Follow code and print for better understanding
SELECT *,
IF(c.sequencia_semana='1','1','nao tem') as semana1,
IF(c.sequencia_semana='2','2','nao tem') as semana2,
IF(c.sequencia_semana='3','3','nao tem') as semana3,
IF(c.sequencia_semana='4','4','nao tem') as semana4,
IF(c.sequencia_semana='5','5','nao tem') as semana5
FROM(SELECT a.cod_cliente, a.razao_social, COUNT(b.id_projetistas), WEEKOFYEAR(b.data_nf) as numero_semana,
(WEEK(b.data_nf) + 1) - WEEK(DATE_ADD(b.data_nf, INTERVAL - DAY(b.data_nf) + 1 DAY)) as sequencia_semana
FROM admin_clientes a LEFT JOIN (SELECT * FROM glasscontrol_projetistas WHERE DATE_FORMAT(glasscontrol_projetistas.data_nf,'%m-%Y')='04-2018') b ON a.cod_cliente=b.cod_cliente_pedido
WHERE a.vendedor_apelido='JANAINA' AND a.situacao='A' AND a.rota_cliente='7'
GROUP BY a.cod_cliente, WEEKOFYEAR(b.data_nf)
ORDER BY a.razao_social, WEEKOFYEAR(b.data_nf)) AS c