0
I’m trying to do a query that needs to bring the month percentage of each row to it I did the query below:
SELECT
linhas,
month(date) as `data`,
round((`M3.0`*0.3),2) + round((Produtividade*0.2),2) + round((qualidade*0.3),2) + round((Produtividade*0.2),2) as soma,
case when month(date) in ('4','5','6') then 'Quartil 1'
when month(date) in ('7','8','9') then 'Quartil 2'
when month(date) in ('10','11','12') then 'Quartil 3'
else 'Quartil 4' end as quartil
FROM
nossa_performance.performance_all
WHERE
MONTH(date) IN ('1','2','3')
GROUP BY linhas,MONTH(date) order by linhas;
query return comes
linhas | mes | percentual
1 01 80%
1 02 95%
1 03 83%
2 01 55%
2 02 67%
2 03 93% ...
and I would like to join the lines and add the percentages tried a subquery did not work: select line, sum, quartile from
( SELECT
linhas as line,
date as `data`,
round((`M3.0`*0.3),2) + round((Produtividade*0.2),2) + round((qualidade*0.3),2) + round((Produtividade*0.2),2) as soma,
case when month(date) in ('4','5','6') then 'Quartil 1'
when month(date) in ('7','8','9') then 'Quartil 2'
when month(date) in ('10','11','12') then 'Quartil 3'
else 'Quartil 4' end as quartil
FROM
nossa_performance.performance_all
WHERE
MONTH(date) IN ('1','2','3')
GROUP BY linhas order by linhas) a group by MONTH(`data`),line;
try to understand, you have two columns, Cola=10 Colb=20 you want to make a calculation of these two columns is this ?
– Risk
i want to take the sum of the percentages of the line that is doubling, like in the example above on line one bring:
– teste1234