I used this query at 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
After having googled for hours to find a way to sum the number of games (P1350
) of each player in all teams (P54
), I decided to ask for some help.
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
}
}