How to unify the value of a column by making a group by of two different columns?

0

I'm trying to do a query that needs to bring the percent of the month of each row to this I made 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 I 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;
    
asked by anonymous 28.11.2018 / 18:47

0 answers