Android获取数据库列的总和,其值如下
用最简单的术语来说,如果我有一个值如下的表Android获取数据库列的总和,其值如下,android,database,sqlite,Android,Database,Sqlite,用最简单的术语来说,如果我有一个值如下的表 x 5 x 7 y 3 v 19 x 24 我想把x的所有int值加起来,不包括y和v等的int值 我目前有返回x的所有列值的工作代码(在本例中为dateAccessed) 然而,我似乎无法将两者结合起来,让它们一起工作。 无论我以何种方式构造游标,它总是失败 如果您在开始时对您的简单示例进行原始查询,我们将非常感谢您提供的任何帮助 select sum(dairyNumber) from yourtable where
x 5
x 7
y 3
v 19
x 24
我想把x的所有int值加起来,不包括y和v等的int值
我目前有返回x的所有列值的工作代码(在本例中为dateAccessed)
然而,我似乎无法将两者结合起来,让它们一起工作。
无论我以何种方式构造游标,它总是失败
如果您在开始时对您的简单示例进行原始查询,我们将非常感谢您提供的任何帮助
select sum(dairyNumber) from yourtable where dairyId = 'x'
or, if you want another column than just the sum .
select diaryName, sum(dairyNumber) from yourtable where dairyId = 'x'
如果要将“x”的值作为参数传递,则可以使用?并提供一个where参数
对于您的特定示例,您的原始查询应该是
select sum(diaryNumber) from yourtable where diaryDate like '201307%'
select diaryName, sum(diaryNumber) from yourtable where diaryDate like '201307%'
希望这对您有所帮助。如果您在开始时对简单示例进行原始查询
select sum(dairyNumber) from yourtable where dairyId = 'x'
or, if you want another column than just the sum .
select diaryName, sum(dairyNumber) from yourtable where dairyId = 'x'
如果要将“x”的值作为参数传递,则可以使用?并提供一个where参数
对于您的特定示例,您的原始查询应该是
select sum(diaryNumber) from yourtable where diaryDate like '201307%'
select diaryName, sum(diaryNumber) from yourtable where diaryDate like '201307%'
希望这能有所帮助。您是否尝试过使用“从someColumn=x的构建器中选择总和(builderNumber)”之类的内容进行原始查询?您是否尝试过使用“从someColumn=x的构建器中选择总和(builderNumber)”之类的内容进行原始查询?