User:MisterSynergy/sports/queries

From Wikidata
Jump to navigation Jump to search

Sportsperson occupations by sport or field of work

[edit]
# sports occupations without field of this occupation
SELECT ?sports_occupation ?sports_occupationLabel ?field_of_work ?field_of_workLabel ?sports ?sportsLabel {
  ?sports_occupation wdt:P279* wd:Q2066131 .
  OPTIONAL {
  	?sports_occupation wdt:P425 ?field_of_work . # required
  }
  OPTIONAL {
  	?sports_occupation wdt:P641 ?sports . # should be empty
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Try it!

Summer Olympic Games editions

[edit]
SELECT ?item ?itemLabel WHERE {
	?item wdt:P31 wd:Q159821 . 
	SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Try it!

Number of disciplines and events at Summer Olympic Games

[edit]
SELECT ?games ?gamesLabel ?disciplines ?events WHERE {
	{
    	SELECT ?games (COUNT(distinct ?discipline) as ?disciplines) (COUNT(distinct ?event) AS ?events) WHERE {
            ?games wdt:P31 wd:Q159821 . 
            ?discipline wdt:P361 ?games . 
            OPTIONAL {
              ?event wdt:P361 ?discipline . 
              ?event wdt:P31 wd:Q18536594 . 
            }
        } GROUP BY ?games
    }

  	SERVICE wikibase:label {
      bd:serviceParam wikibase:language "en" . 
    }
} ORDER BY ASC(?gamesLabel)
Try it!

Instance of sport or subclasses thereof

[edit]
SELECT ?item ?itemLabel ?sport ?sportLabel {
  ?item wdt:P31 ?sport .
  ?sport wdt:P279* wd:Q349 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } .
}
Try it!

Sports seasons and unseasoned sport competitions

[edit]

Watching: use of sports season of league or competition (P3450); this property should be used in season (Q27020041) items, since the typical class/instance model does not fit here. However, they should not replace class/instance relations for all sport competitions.

SELECT ?league ?leagueLabel ?isLeague ?isCup ?isOrganization (COUNT(DISTINCT ?season) AS ?seasons) WHERE {
  ?season wdt:P3450 ?league .
  BIND(EXISTS { ?league wdt:P31/wdt:P279* wd:Q623109 } AS ?isLeague) .
  BIND(EXISTS { ?league wdt:P31/wdt:P279* wd:Q61629906 } AS ?isCup) .
  BIND(EXISTS { ?league wdt:P31/wdt:P279* wd:Q43229 } AS ?isOrganization) .
  FILTER(!(?isLeague|| ?isCup || ?isOrganization)) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?league ?leagueLabel ?isLeague ?isCup ?isOrganization
Try it!

Evaluate a particular sport competition (replace wd:Q6834 by the particular sport competition item in question in line 2)

SELECT ?season ?seasonLabel ?season_follows ?season_followed_by ?competition ?competitionLabel ?isSeason ?isCompetition WHERE {
  BIND(wd:Q6834 AS ?competition) .
  ?season p:P3450 ?competitionStatement .
  ?competitionStatement ps:P3450 ?competition .
  OPTIONAL { ?competitionStatement pq:P155 ?season_follows }
  OPTIONAL { ?competitionStatement pq:P156 ?season_followed_by }
  BIND(EXISTS { ?season wdt:P31/wdt:P279* wd:Q27020041 } AS ?isSeason) .
  BIND(EXISTS { ?season wdt:P31/wdt:P279* ?competition } AS ?isCompetition) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} ORDER BY ASC(?seasonLabel)
Try it!

Weight classes

[edit]
SELECT ?item ?itemLabel ?itemDescription (GROUP_CONCAT(DISTINCT ?sport; SEPARATOR=', ') AS ?sports) ?any WHERE {
  ?item ?any [ wdt:P279* wd:Q17080472 ] .
  [] wikibase:directClaim ?any .
  FILTER(?any NOT IN (wdt:P2094)) .
  OPTIONAL { ?item wdt:P641/rdfs:label ?sport . FILTER(LANG(?sport) = 'en') }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
  MINUS { ?item wdt:P31 wd:Q4167836 }
  FILTER(?item NOT IN (wd:Q1520639, wd:Q7674850, wd:Q7248117, wd:Q2943040, wd:Q6404298, wd:Q1326107, wd:Q2531472)) .
} GROUP BY ?item ?itemLabel ?itemDescription ?any ORDER BY ASC(?itemLabel)
Try it!
SELECT ?item ?itemLabel (GROUP_CONCAT(DISTINCT ?instance; SEPARATOR=', ') AS ?instances) (GROUP_CONCAT(DISTINCT ?superclass; SEPARATOR=', ') AS ?superclasses) (GROUP_CONCAT(DISTINCT ?backlink; SEPARATOR=', ') AS ?backlinks) (GROUP_CONCAT(DISTINCT ?sport; SEPARATOR=', ') AS ?sports) WHERE {
  VALUES ?item {
#    wd:Q1054759 wd:Q3900728 wd:Q646800 wd:Q1054925 wd:Q1054751 wd:Q5439659 wd:Q1055190 wd:Q1055125 wd:Q7642947 wd:Q76817070 wd:Q6499041 wd:Q76817032 wd:Q4817392 wd:Q39078865 wd:Q48835784 wd:Q48835853 wd:Q48835875 # Q2943040 / MMA (complete); en:Template:MMA weight classes
#    wd:Q1051530 wd:Q281678 wd:Q1051922 wd:Q948780 wd:Q597315 wd:Q766904 wd:Q507205 wd:Q1004748 wd:Q508484 wd:Q282168 wd:Q867600 wd:Q645063 wd:Q1215222 wd:Q1096810 wd:Q1112498 wd:Q7642939 wd:Q763947 wd:Q1048358 wd:Q11699026 wd:Q955185 wd:Q7196574 # Q1326107 / boxing; en:Template:Boxing weight classes
#    wd:Q76833043 wd:Q76833083 wd:Q76833079 wd:Q76833056 wd:Q76833074 wd:Q76833097 wd:Q76833047 wd:Q76833053 wd:Q76833113 wd:Q76833059 wd:Q76833051 wd:Q76833129 wd:Q76833241 wd:Q76833226 wd:Q76833179 wd:Q76833210 wd:Q76833257 wd:Q76833143 wd:Q76833162 wd:Q76833194 wd:Q76833147 # Q1520639 / wrestling
#    wd:Q77000006 wd:Q77000008 wd:Q77000010 wd:Q77000013 wd:Q77000014 wd:Q77000017 wd:Q77000020 wd:Q77000022 wd:Q77000024 wd:Q77000027 wd:Q77000028 wd:Q77000030 wd:Q77000032 wd:Q77000033 wd:Q77000035 wd:Q77000037 wd:Q77000041 wd:Q77000042 wd:Q77000045 wd:Q77000046 wd:Q77000048 wd:Q77000051 wd:Q77000054 wd:Q77000057 wd:Q77000060 wd:Q77000062 wd:Q77000066 wd:Q77000069 wd:Q77000071 wd:Q77000073 wd:Q77000077 wd:Q77000079 wd:Q77000081 wd:Q77000084 wd:Q77000087 wd:Q77000089 # Q7674850 / taekwondo; :de:Gewichtsklasse#Taekwondo
#    wd:Q77217210 wd:Q77217208 wd:Q77217209 wd:Q77217215 wd:Q77217218 wd:Q77217224 wd:Q77217228 wd:Q77217235   # Q77217027 / judo
# Q6404298 / kickboxing
# Q7248117 / professional_wrestling
# weightlifting
# powerlifting (Q213796)
# karate
#    wd:Q26211786 wd:Q26211781 # rowing
  }
  OPTIONAL { ?item wdt:P31/rdfs:label ?instance . FILTER(LANG(?instance) = 'en') }
  OPTIONAL { ?item wdt:P279/rdfs:label ?superclass . FILTER(LANG(?superclass) = 'en') }
  OPTIONAL { ?item wdt:P641/rdfs:label ?sport . FILTER(LANG(?sport) = 'en') }
  OPTIONAL { ?backlinkItem wdt:P527 ?item; rdfs:label ?backlink . FILTER(LANG(?backlink) = 'en') }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?item ?itemLabel
Try it!

COVID-19 positive Olympians

[edit]
SELECT DISTINCT
  ?item
  ?itemLabel
  (GROUP_CONCAT(DISTINCT ?citizenship; SEPARATOR=', ') AS ?citizenships)
  (GROUP_CONCAT(DISTINCT ?occupation; SEPARATOR=', ') AS ?occupations)
  ?startTime
  (COUNT(?refHandle) AS ?cnt_refs)
  ?sr_url
WHERE {
  ?item wdt:P1447 ?sr; p:P1050 ?s .
  BIND(IRI(CONCAT('https://www.sports-reference.com/olympics/athletes/', ?sr, '.html')) AS ?sr_url)
  OPTIONAL { ?item wdt:P27/rdfs:label ?citizenship . FILTER(LANG(?citizenship) = 'en') }
  OPTIONAL { ?item wdt:P106/rdfs:label ?occupation . FILTER(LANG(?occupation) = 'en') }
  ?s ps:P1050 wd:Q84263196 .
  OPTIONAL { ?s pq:P580 ?startTime }
  OPTIONAL { ?s prov:wasDerivedFrom ?refHandle }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?item ?itemLabel ?startTime ?sr_url
Try it!