Help with creating ABC curve in Mysql

2

I mounted a select to know how many products sold in a given period and the sales value of these products.

I need to mount an ABC curve with the result of this select.

Someone could help me please.

My select looks 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 table lc_controle 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 over the total sale and then set whether it is A, b or C

How can you do this?

    
asked by anonymous 01.04.2018 / 23:50

0 answers