2017-08-24 84 views
2

我用這個查詢在https://query.wikidata.org/ -維基數據:SPARQL,足球運動員的比賽數量

SELECT ?p ?pLabel (?oc as ?OC) (?sp as ?SP) WHERE { 

?p wdt:P106/wdt:P279* wd:Q937857. # Soccer player 

SERVICE wikibase:label {bd:serviceParam wikibase:language "en" . } 

{ SELECT ?p (count(?oc) AS ?oc) WHERE { ?p wdt:P106 wd:Q937857; p:P106 ?oc. } GROUP BY ?p HAVING(?oc<3)} # Occupation 

{ SELECT ?p (count(?sp) AS ?sp) WHERE { ?p wdt:P106 wd:Q937857; p:P54 ?sp. } GROUP BY ?p HAVING(?sp>5)} # Sport Teams                         
} 

LIMIT 10 

Query link

已經用Google搜索小時後找到一種方法來概括遊戲的數量(P1350)所有球隊的每名球員(P54),我決定尋求一些幫助。

回答

3
SELECT ?player ?playerLabel ?totalMatchesPlayed { 

SERVICE wikibase:label {bd:serviceParam wikibase:language "en" . } 

{ 
    SELECT ?player (sum(?matchesPlayed) as ?totalMatchesPlayed) WHERE { 
    ?player wdt:P106/wdt:P279* wd:Q937857 . 
    ?player p:P54/pq:P1350 ?matchesPlayed. 
    } 
    GROUP BY ?player 
    LIMIT 100 
} 

} 
+0

它的工作原理!非常感謝你。 –