只有在SPARQL中某些条件成立时才需要进行计数,类似这样(不起作用):
SELECT ...
COUNT(FILTER(?qualisScoreValue = "A1")) ?QNTD_A1 .
COUNT(FILTER(?qualisScoreValue = "A2")) ?QNTD_A2 .
COUNT(FILTER(?qualisScoreValue = "B1")) ?QNTD_B1 .
我知道mysql,我认为我需要的东西在mysql这样的情况下应该是等效的(有效):
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,
答案 0 :(得分:3)
而不是计数,使用 sum 和 if 函数。如,
select (sum(if(condition, 1, 0)) as ?conditionCount) ...