How to do sum and count in MySQL?

0

I have query that brings up the number of rows of a given fault.

select falhas, 
       count(falhas) 
  from tabela 
 where semana = 'semana-5' 
 group by falhas 
 order by count(falhas) desc;

The result has the following values:

3 
2 
1
1
1

I need to add the first value with the second, and the sum of the two with the third, and so on. Does anyone know a way to do this in MySQL .

I wanted it to display 3 + 2 = 5. put the final score 5 + 1, and there goes line1 displays 5 line2 displays 6 line3 displays 7

or a way to break mysql_fetch_array into string.

    
asked by anonymous 29.06.2016 / 20:31

1 answer

0
SELECT b.falhas, SUM(a.falhas)
FROM tabela AS a, tabela AS b
WHERE a.id <= b.id
GROUP BY b.falhas
ORDER BY b.falhas DESC
    
29.06.2016 / 21:08