我在https://query.wikidata.org/ -
使用了此查询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
用Google搜索了几个小时后,找到了一种方法来计算所有球队(P1350
)中每位球员的比赛次数(P54
),我决定寻求帮助。
答案 0 :(得分: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
}
}