我在这里遇到了一个问题,看起来很简单,但是因为我对 Sparal 查询不太熟悉,所以我找不到解决方案。
PREFIX onto: <http://dbpedia.org/ontology/>
PREFIX resu: <http://dbpedia.org/resource/>
PREFIX yago: <http://dbpedia.org/class/yago/>
SELECT
count(?MontrealC) as ?Montrea
count(?TorontoC) as ?Toronto
count(?OttawaC) as ?Ottawa
count(?VancouverC) as ?Vancouver
WHERE
{
{?MontrealC rdf:type yago:HotelsInMontreal} UNION
{?TorontoC rdf:type yago:HotelsInToronto} UNION
{?OttawaC rdf:type yago:HotelsInOttawa} UNION
{?VancouverC a onto:Hotel .
{?VancouverC onto:location resu:Vancouver} UNION
{?VancouverC onto:location ?street .
?street a yago:StreetsInVancouver}} UNION
{?VancouverC a yago:HotelsInBritishColumbia .
{?VancouverC onto:location resu:Vancouver} UNION
{?VancouverC onto:location ?street.
?street a yago:StreetsInVancouver}
}}
在任何 dbpedia 端点中应用此查询后,您将获得以两行和四列显示的结果,如下所示:
Montreal Toronto Ottawa Vancouver
8 28 5 10
问题是我需要它们在两列和四行中,如下所示:
Montreal Toronto
8 28
Ottawa Vancouver
5 10
这在 SPARQL 查询中可能吗?