Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
选择sum并按SQLITE分组_Sqlite_Sum - Fatal编程技术网

选择sum并按SQLITE分组

选择sum并按SQLITE分组,sqlite,sum,Sqlite,Sum,我有一个包含4个字段(id、name、role、points)的sqlite表,我需要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 为了执行聚合函数,

我有一个包含4个字段(id、name、role、points)的sqlite表,我需要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 

为了执行聚合函数,必须首先对列进行分组

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