按SQLITE选择sum和group

时间:2017-03-29 19:36:05

标签: sqlite sum

我有一个带有4个字段的sqlite表(id,name,role,points)我想要字段点的总和WHERE role ='something'和name ='something'

我的查询无效:

select id,name,role, points (select sum(points) 
from salvataggi_punti_giocatori where role = 'por') 
as total from salvataggi_punti_giocatori 

1 个答案:

答案 0 :(得分:2)

您必须先对列进行分组才能执行聚合函数

SELECT  sum(points) 
  FROM  salvataggi_punti_giocatori
  WHERE role = 'value'
  AND   name = 'value'
  GROUP BY role, name