3
I set up a select to know how many products were sold in a given period and the sale value of those products.
Only I need to mount an ABC curve with the result of this select.
Could someone please help me.
My select is like this:
SELECT DISTINCT d.cat_id prod, p.id, p.nome id_prod, SUM( d.qtd ) AS qtd_prod, SUM( d.valor_total ) AS total_prod
FROM lc_controle c
INNER JOIN lc_detalhe d ON d.controle_id = c.id
INNER JOIN `lc_cat` p ON p.id = d.cat_id
WHERE d.tipo = '0'
AND c.dtConcat
BETWEEN '2018-01-01'
AND '2018-03-31'
GROUP BY d.cat_id
ORDER BY qtd_prod DESC
With this select I have the following result:
prod id id_prod qtd_prod total_prod
43 43 JVP-101A - BOMBA DE CIRCULAÇÃO 3.000 L/H 110V 353 12983.24
41 41 JVP-100A - BOMBA DE CIRCULAÇÃO 2.500 L/H 110V 352 10704.09
148 148 JVP-110A - BOMBA DE CIRCULAÇÃO 2.000 L/H 110V 242 7495.04
78 78 HJS-20 CARVÃO ATIVADO 500GR 208 1497.87
252 252 JVP-120 - BOMBA DE CIRCULAÇÃO 3.000 L/H 110V 181 5753.87
Now I need to add the sales values that are in the lc_control table to the total column for the same period and then divide the sales value of each item by this total to be able to calculate the percentage that the item has on the total sale and then define whether it is A, b or C
How is it possible to do this?