Mysql query select several months in different columns

0

I am trying to make a query in which all the clients of a year separate me and their faturation for each month in a column. I give example:

Cliente    Enero    Febrero    Marzo ....

cliente1     300       350       800

cliente2     500       20        300

cliente3     30        40        120

I managed to get the clients out of a month and their billing but I do not know how to continue from there

SELECT distinct c.cliente,sum(s.facturacion) as total  FROM datos.facturacion s
join datos.clientes c on s.cliente=c.id_cliente
where s.fecha BETWEEN '2018-01-01' AND '2018-01-31' GROUP BY cliente;

Cliente    total

cliente1     300 

cliente2     500 

cliente3     30 

I would appreciate a help if someone knows how it could be done

    
asked by hayber 04.03.2018 в 17:23
source

0 answers