Reputation: 195
I have a sqlite table with 4 fields (id, name, role, points) i want the sum of field points WHERE role = 'something' AND name = 'something'
My query does not work correctly:
select id,name,role, points (select sum(points)
from salvataggi_punti_giocatori where role = 'por')
as total from salvataggi_punti_giocatori
Upvotes: 1
Views: 1410
Reputation: 2537
You have to group the columns first in order to perform aggregate functions
SELECT sum(points)
FROM salvataggi_punti_giocatori
WHERE role = 'value'
AND name = 'value'
GROUP BY role, name
Upvotes: 3