Scroll through the table, check the name and add the total

Today I have to be stupid. I have a table with the same data that includes (among other things) company names and integer values. I need to select one row, check every time that name appears in the database, and add an integer value from this row to the common one.

ex.

 28469151 6398   80609     40032 CITY TREASURER
 25404033 6289   041409CR 39926 CITY TREASURER
 2408266  8473    071009    40017  CITY TREASURER
 22332527 9710   2009     39975 THE ST JOE COMPANY
 21570825 6857   051209CR 39954 CITY TREASURER

the program will add the number from line 2 each time it sees the "city treasurer". any ideas? There are about 4000 entries

Edit: I need to get the total quantity for each company in the table.

+3
source share
2 answers

I assume something like this (suppose the first col is called col1)

select sum(col1) from table group by company;
+3
source
SELECT SUM(`field1name`) FROM `table` GROUP BY `field2name`
0
source

Source: https://habr.com/ru/post/1784731/


All Articles