Total sales per month grouped by seller

2

I need to bring a listing of executives and their total sales per month, this is all regardless of having a sale in the month or not.

For years I've been focused on front-end and never done anything with sql, can you help me?

vendedor   janeiro fevereiro marco abril maio junho julho agosto ...

vendedor1  300     400       800   0     0    0     0     0
vendedor2  100     50        30    0     100  50    0     0
    
asked by anonymous 02.11.2018 / 23:23

1 answer

2

Good afternoon! Please inform me if the code works correctly. Thank you.

SELECT 
sum(janeiro) AS total_jan,
sum(fevereiro) AS total_fev,
sum(marco) AS total_mar,
sum(abril) AS total_abr,
sum(maio) AS total_mai,
sum(junho) AS total_jun,
sum(julho) AS total_jul,
sum(agosto) AS total_ago,
sum(setembro) AS total_set,
sum(outubro) AS total_out,
sum(novembro) AS total_nov,
sum(dezembro) AS total_dez
FROM nome_da_tabela
GROUP BY vendedor;
    
03.11.2018 / 18:12