im7xs
im7xs

Reputation: 195

Select sum and group by SQLITE

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

Answers (1)

Kurt Acosta
Kurt Acosta

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

Related Questions