sparql select 多次计数 return 不同的结果
sparql select multiple count return different results
我运行在Protégé中对相同数据
进行了以下查询
SELECT (COUNT(?VM) AS ?count_VM)
WHERE {
?VM a cocoon:VM .
}
正确地给我 57
SELECT (COUNT(?storage) AS ?count_storage)
WHERE {
?storage a cocoon:Storage .
}
正确地给我 8
但是
SELECT (COUNT(?VM) AS ?count_VM) (COUNT(?storage) AS ?count_storage)
WHERE {
?VM a cocoon:VM .
?storage a cocoon:Storage .
}
给我
"456"^^<http://www.w3.org/2001/XMLSchema#integer>
?count_VM
和 ?count_storage
怎么了?
AKSW更好的回答:
select ?cls (count(?s) AS ?count)
{VALUES ?cls {cocoon:Storage cocoon:VM} ?s a ?cls}
group by ?cls
Stanislav Kralin 的旧回答:
select * {
{
select (count(?storage) AS ?count_storage)
{ ?storage a cocoon:Storage . }
}
{
select (count(?VM) AS ?count_VM)
{ ?VM a cocoon:VM . }
}
}
我运行在Protégé中对相同数据
进行了以下查询SELECT (COUNT(?VM) AS ?count_VM)
WHERE {
?VM a cocoon:VM .
}
正确地给我 57
SELECT (COUNT(?storage) AS ?count_storage)
WHERE {
?storage a cocoon:Storage .
}
正确地给我 8
但是
SELECT (COUNT(?VM) AS ?count_VM) (COUNT(?storage) AS ?count_storage)
WHERE {
?VM a cocoon:VM .
?storage a cocoon:Storage .
}
给我
"456"^^<http://www.w3.org/2001/XMLSchema#integer>
?count_VM
和 ?count_storage
怎么了?
AKSW更好的回答:
select ?cls (count(?s) AS ?count)
{VALUES ?cls {cocoon:Storage cocoon:VM} ?s a ?cls}
group by ?cls
Stanislav Kralin 的旧回答:
select * {
{
select (count(?storage) AS ?count_storage)
{ ?storage a cocoon:Storage . }
}
{
select (count(?VM) AS ?count_VM)
{ ?VM a cocoon:VM . }
}
}