如何在SPARQL中使用条件(IF或FILTER)进行计数

如何在SPARQL中使用条件(IF或FILTER)进行计数,sparql,Sparql,只有当SPARQL中的某些条件为真时,我才需要进行计数,类似这样的情况(不起作用): 我知道mysql,我认为在mysql语言中,我所需要的应该是等价的(可以使用): 使用sum和if函数,而不是count。例如: select (sum(if(condition, 1, 0)) as ?conditionCount) ... select ... count(case when q.nameQualis = 'A1' then 1 else null end) as qntd_A1, cou

只有当SPARQL中的某些条件为真时,我才需要进行计数,类似这样的情况(不起作用):

我知道mysql,我认为在mysql语言中,我所需要的应该是等价的(可以使用):


使用sumif函数,而不是count。例如:

select (sum(if(condition, 1, 0)) as ?conditionCount) ...
select ...
count(case when q.nameQualis = 'A1' then 1 else null end) as qntd_A1,
count(case when q.nameQualis = 'A2' then 1 else null end) as qntd_A2,
count(case when q.nameQualis = 'B1' then 1 else null end) as qntd_B1,
select (sum(if(condition, 1, 0)) as ?conditionCount) ...