尝试在同一个SPARQL查询中获得三个(或更多计数结果:
SELECT
?cs
?bs
?ws
WHERE {
{ SELECT (COUNT(?c) AS ?cs) WHERE { ?c a :OneThing . }}
UNION
{ SELECT (COUNT(?b) AS ?bs) WHERE { ?b a :AnotherThing . } }
UNION
{ SELECT (COUNT(?w) AS ?ws) WHERE { ?w a :ThirdThing . } }
}
然而,如果结果只有一行而不是三行(以及对角线上的计数)会更好。试过不同的表达无济于事。
使用SPARQL可以有效地完成吗?我觉得我错过了一些明显的东西......
答案 0 :(得分:4)
这可以解决这个问题吗?
SELECT (COUNT(?c) AS ?cs) (COUNT(?b) AS ?bs) (COUNT(?w) AS ?ws)
WHERE {
{ ?c a :OneThing . }
UNION
{ ?b a :AnotherThing . }
UNION
{ ?w a :ThirdThing . }
}