Generate MySQL dynamic header

0

I have below a problem that I can not solve.

How do I get the header to have the employee's name and below it the revenue that was generated by the date?

And how would an HTML table look like these?

The first image is a simple query that I set up just to demonstrate the structure of my table.

The second is what I want it to look like.

@EDIT I can do something similar, but now I do not know how I will set up my HTML table. The IDS and names will be dynamic, where I will set up according to every employee I have in my bank. I put static just as an example.

SELECT P.dt_venda as venda, 
SUM(CASE WHEN P.id_consultor = 4 THEN IR.receita_gerada_receita END) as funcionario4,
SUM(CASE WHEN P.id_consultor = 3 THEN IR.receita_gerada_receita END) as funcionario3,
SUM(CASE WHEN P.id_consultor = 2 THEN IR.receita_gerada_receita END) as funcionario2
FROM item_receitas as IR, funcionarios as F, pedidos as P
WHERE P.id_consultor = F.id
AND IR.id_pedido = P.id
GROUP BY venda, F.nome

    
asked by anonymous 30.08.2017 / 20:53

0 answers