使用 SPARQL 计数:如何在一行中获得结果?
Counting with SPARQL: how to get results in one row?
尝试在同一个 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 高效地完成吗?我觉得我错过了一些明显的东西......
这样做有用吗?
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 . }
}
尝试在同一个 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 高效地完成吗?我觉得我错过了一些明显的东西......
这样做有用吗?
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 . }
}