Skip to content
Advertisement

SQL count Occurency trouble

I’m pretty new in the SQL world and i have some troubles about counting some row. I explain myself:

I have a DB like this:

NAME | (somenumbers)|
L1   | 2
L1   | 2
L2   | 3
L3   | 1
L3   | 1
L3   | 1

I expected result like this [L1:4,L2:3,L3:3], i have tried to read and test some count, group by or distinct but I am missing something. So if some people can help me, i would appreciate.

Advertisement

Answer

use sum() instead count()

select name,sum(somenumbers) from table_name
group by name
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement