Jump to content

User:Wolbo/sandbox5

From Wikipedia, the free encyclopedia

Wikidata query service (SPARQL)[edit]

Players[edit]

Tournaments won by Ivan Lendl[edit]

SELECT ?event ?eventLabel ?tournamentLabel ?year ?countryLabel ?surfaceLabel ?purse ?participants
WHERE 
{
  ?event wdt:P1346 wd:Q182736 . 
  OPTIONAL { ?event wdt:P361 ?tournament . 
             OPTIONAL { ?tournament wdt:P765 ?surface . }
             OPTIONAL { ?tournament wdt:P2121 ?purse . }
             OPTIONAL { ?tournament wdt:P17 ?country . }
           }
  OPTIONAL { ?event wdt:P585 ?time . BIND(year(?time) as ?year) }  
  OPTIONAL { ?event wdt:P1132 ?participants . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
}

Click here to launch the Wikidata query

Count tennis players by gender[edit]

SELECT ?genderLabel (count(?gender) as ?count) 
WHERE 
{
  ?item wdt:P106 wd:Q10833314.
  ?item wdt:P21 ?gender .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} group by ?genderLabel

Click here to launch the Wikidata query

ITF 2020[edit]

SELECT ?itfLabel (count(?itf2020) as ?count) 
WHERE 
{
  ?item wdt:P8618 ?itf2020 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} group by ?itfLabel

Click here to launch the Wikidata query

List of tennis siblings[edit]

#Cats
SELECT distinct ?item ?itemLabel ?item2 ?item2Label 
WHERE 
{
  ?item wdt:P106 wd:Q10833314.
  ?item2 wdt:P106 wd:Q10833314.
  {?item wdt:P3373 ?item2 .}
  UNION
  {?item2 wdt:P3373 ?item .}
  filter (strafter(str(?item),"Q") < strafter(str(?item2),"Q") )  #remove if you wish
  ?item rdfs:label ?itemLabel . filter(lang(?itemLabel)="en")
  ?item2 rdfs:label ?item2Label . filter(lang(?item2Label)="en")
  bind(strafter(?itemLabel, " ") as ?index)
  bind(strbefore(?itemLabel, " ") as ?index2)
} order by ?index ?index2

Click here to launch the Wikidata query

List of female Indian tennis players[edit]

SELECT ?item ?itemLabel ?itemDescription (SAMPLE(?img) AS ?image) (SAMPLE(?dob) AS ?dob) ?sl WHERE {
  ?item wdt:P106 wd:Q10833314.
  ?item wdt:P27 wd:Q668.
  ?item wdt:P21 wd:Q6581072.
  MINUS { ?item wdt:P570 _:b0. }
  OPTIONAL { ?item wdt:P18 ?img. }
  OPTIONAL { ?item wdt:P569 ?dob. }
  OPTIONAL { ?item wikibase:sitelinks ?sl. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?item ?itemLabel ?itemDescription ?sl
ORDER BY DESC(?sl)

Click here to launch the Wikidata query

Edited tennis player items[edit]

SELECT ?date ?item ?itemLabel ?nameLabel ?surnameLabel ?sexLabel ?countryLabel WHERE {
  ?item wdt:P106 wd:Q10833314 ; schema:dateModified ?date .
  FILTER ( ?date > "2019-04-01T00:00:00Z"^^xsd:dateTime )
  OPTIONAL { ?item wdt:P735 ?name } .
  OPTIONAL { ?item wdt:P734 ?surname } .
  OPTIONAL { ?item wdt:P21 ?sex } .
  OPTIONAL { ?item wdt:P27 ?country } .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } .
}
ORDER BY ?date

Click here to launch the Wikidata query

Oldest living tennis players[edit]

SELECT ?item ?itemLabel ?birth ?genderLabel ?age WHERE {
  ?item wdt:P106 wd:Q10833314 ; wdt:P569 ?birth ; wdt:P21 ?gender .
  MINUS { ?item wdt:P570 [] } .
  BIND(YEAR(now())-YEAR(?birth) as ?age) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?age)
LIMIT 100

Click here to launch the Wikidata query

Limited to 110 years of age:

SELECT ?item ?itemLabel ?birth ?genderLabel ?age WHERE {
  ?item wdt:P106 wd:Q10833314 ; wdt:P569 ?birth ; wdt:P21 ?gender .
  MINUS { ?item wdt:P570 [] } .
  BIND(YEAR(now())-YEAR(?birth) as ?age) .
  FILTER ( ?age < 110 )
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?age)
LIMIT 100

Click here to launch the Wikidata query

Oldest living tennis players who won a Grand Slam singles title[edit]

SELECT ?item ?itemLabel ?birth ?genderLabel ?age WHERE {
  ?item wdt:P106 wd:Q10833314 ; wdt:P569 ?birth ; wdt:P21 ?gender .
  MINUS { ?item wdt:P570 [] } .
  BIND(YEAR(now())-YEAR(?birth) as ?age) .
  FILTER ( ?age < 110 )
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?age)
LIMIT 100

Click here to launch the Wikidata query

or

Women's singles[edit]
SELECT DISTINCT ?item ?itemLabel ?birth ?genderLabel ?age WHERE {
  ?item wdt:P106 wd:Q10833314 ; wdt:P569 ?birth ; wdt:P21 ?gender .
  MINUS { ?item wdt:P570 [] }
#  BIND(YEAR(now())-YEAR(?birth) as ?age)
  BIND( YEAR(now()) - YEAR(?birth) - 
              IF(MONTH(now())<MONTH(?birth) || 
                 (MONTH(now())=MONTH(?birth) && DAY(now())<DAY(?birth)),1,0) AS ?age )
  FILTER ( ?age < 110 )
  ?tournament wdt:P1346 ?item . 
  ?tournament wdt:P2094 wd:Q16893403 . # women's singles
  ?tournament wdt:P361 / wdt:P31 / wdt:P361 wd:Q102113 . # part of / instance of / part of Grand Slam
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?age)
LIMIT 100

Click here to launch the Wikidata query

Men's singles[edit]
SELECT DISTINCT ?item ?itemLabel ?birth ?genderLabel ?age WHERE {
  ?item wdt:P106 wd:Q10833314 ; wdt:P569 ?birth ; wdt:P21 ?gender .
  MINUS { ?item wdt:P570 [] }
#  BIND(YEAR(now())-YEAR(?birth) as ?age)
  BIND( YEAR(now()) - YEAR(?birth) - 
              IF(MONTH(now())<MONTH(?birth) || 
                 (MONTH(now())=MONTH(?birth) && DAY(now())<DAY(?birth)),1,0) AS ?age )
  FILTER ( ?age < 110 )
  ?tournament wdt:P1346 ?item . 
  ?tournament wdt:P2094 wd:Q16893072 . # men's singles
  ?tournament wdt:P361 / wdt:P31 / wdt:P361 wd:Q102113 . # part of / instance of / part of Grand Slam
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?age)
LIMIT 100

Click here to launch the Wikidata query

Women's doubles[edit]
SELECT DISTINCT ?item ?itemLabel ?birth ?genderLabel ?age WHERE {
  ?item wdt:P106 wd:Q10833314 ; wdt:P569 ?birth ; wdt:P21 ?gender .
  MINUS { ?item wdt:P570 [] }
#  BIND(YEAR(now())-YEAR(?birth) as ?age)
  BIND( YEAR(now()) - YEAR(?birth) - 
              IF(MONTH(now())<MONTH(?birth) || 
                 (MONTH(now())=MONTH(?birth) && DAY(now())<DAY(?birth)),1,0) AS ?age )
  FILTER ( ?age < 110 )
  ?tournament wdt:P1346 ?item . 
  ?tournament wdt:P2094 wd:Q17299348 . # women's doubles
  ?tournament wdt:P361 / wdt:P31 / wdt:P361 wd:Q102113 . # part of / instance of / part of Grand Slam
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?age)
LIMIT 100

Click here to launch the Wikidata query

Male tennis players who won a Grand Slam singles title by height[edit]

SELECT DISTINCT ?winner ?winnerLabel ?height_in_cm WHERE {
  ?x wdt:P31 wd:Q46190676 .                  # x is a tennis event
  ?x wdt:P2094 wd:Q16893072 .                # x's competiion class is men's singles
  ?x wdt:P361/wdt:P31/wdt:P361 wd:Q102113  . # x is part of a tournament that is part of a grand slam event
  ?x wdt:P1346 ?winner .                     # x has a winner
  ?winner  p:P2048/psn:P2048 [               # the winner has a height
     wikibase:quantityAmount ?height         # get normalized units (in metres)
  ] .
  BIND (100 * ?height AS ?height_in_cm)      # convert to centimetres
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC (?height_in_cm)                # order by height, tallest first

Click here to launch the Wikidata query

or

WHERE
{
  ?player wdt:P31 wd:Q5 . # ?player is human
  ?player wdt:P21 wd:Q6581097 . # ?player is male
  ?player wdt:P106 wd:Q10833314 . # ?player is tennis player
  OPTIONAL {
    ?player p:P2048 / psn:P2048 / wikibase:quantityAmount ?normalized_height .
     BIND (?normalized_height * 100 AS ?height_in_cm)
  }
  
  wd:Q102113 wdt:P527 ?grand_slam . # ?grand_slam is a tennis grand slam tournament
  ?grand_slam_for_year wdt:P31 ?grand_slam . # ?grand_slam_for_year is a grand slam tourmament for a certain year
  ?event wdt:P361 ?grand_slam_for_year . # event is grand slam event
  ?event wdt:P2094 wd:Q16893072 . # event is a men's singles event
  ?event wdt:P1346 ?player . # ?player won ?event
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?player ?playerLabel ?height_in_cm
ORDER BY DESC(?height_in_cm)

Click here to launch the Wikidata query

Tournaments[edit]

Dutch Open editions[edit]

SELECT ?item ?itemLabel ?country ?countryLabel ?startdate ?enddate ?pointintime ?prizemoney ?follows ?followsLabel ?followedby ?followedbyLabel ?edition ?city ?cityLabel ?surface ?surfaceLabel WHERE {
  ?item wdt:P31 wd:Q299126; 
  OPTIONAL { ?item wdt:P17 ?country }
  OPTIONAL { ?item wdt:P580 ?startdate }
  OPTIONAL { ?item wdt:P582 ?enddate }
  OPTIONAL { ?item wdt:P585 ?pointintime }
  OPTIONAL { ?item wdt:P2121 ?prizemoney }
  OPTIONAL { ?item wdt:P155 ?follows }
  OPTIONAL { ?item wdt:P156 ?followedby }
  OPTIONAL { ?item wdt:P276 ?location }
  OPTIONAL { ?item wdt:P393 ?edition }
  OPTIONAL { ?item wdt:P131 ?city}
  OPTIONAL { ?item wdt:P765 ?surface }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} ORDER BY ASC(?pointintime)

Click here to launch the Wikidata query

1990 WTA Tour[edit]

SELECT ?item ?itemLabel ?start ?end ?countryLabel ?edition ?surfaceLabel ?locationLabel ?prize WHERE {
  ?item wdt:P31 wd:Q47345468;
    wdt:P361 wd:Q1134303. #Q299823 1990 ATP Tour Q85737870 2021 ATP Tour
    # ATP 1970-Q3465182 1971-Q3465199 1972-Q3465206 1973-Q3465217 1974-Q3465223 1975-Q3465233 1976-Q3465243 1977-Q3465249 1978-Q3465257 1979-Q3465264 
    # ATP 1980-Q3465272 1981-Q530872 1982-Q15056435 1983-Q3465290 1984-Q3465300 1985-Q3465309 1986-Q3465325 1987-Q3465336 1988-Q3465350 1989-Q3465367
    # ATP 1990-Q299823 1991-Q299829 1992-Q299830 1993-Q299837 1994-Q299843 1995-Q299844 1996-Q299850 1997-Q299852 1998-Q299855 1999-Q299857
    # ATP 2000-Q299861 2001-Q299865 2002-Q299868 2003-Q299872 2004-Q299873 2005-Q299878 2006-Q299883 2007-Q299889 2008-Q299894 2009-Q300011
    # WTA 1971-Q593596 1972-Q2537927 1973-Q1268177 1974-Q2537934 1975-Q1626589 1976-Q1350710 1977-Q2537943 1978-Q137873 1979-Q931394
    # WTA 1980-Q2537948 1981-Q2537953 1982-Q2537957 1983-Q1138153 1984-Q524023 1985-Q1482022 1986-Q1137877 1987-Q1137553 1988-Q377631 1989-Q1137713
    # WTA 1990-Q1134303 1991-Q958573 1992-Q1134260 1993-Q1134270 1994-Q1134492 1995-Q1134854 1996-Q1134846 1997-Q978103 1998-Q1135160 1999-Q1135172
    # WTA 2000
    # WTA 2010
  OPTIONAL { ?item wdt:P580 ?start. }
  OPTIONAL { ?item wdt:P582 ?end. }
  OPTIONAL { ?item wdt:P17 ?country. }
  OPTIONAL { ?item wdt:P393 ?edition. }
  OPTIONAL { ?item wdt:P765 ?surface. }
  OPTIONAL { ?item wdt:P131 ?location. }
  OPTIONAL { ?item wdt:P2121 ?prize. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ASC(?start)

Click here to launch the Wikidata query

Version 2

SELECT ?item ?itemLabel ?y ?start ?end ?countryLabel ?surfaceLabel ?locationLabel ?unit ?prize ?partof ?partofLabel ?partof2 ?partof2Label
WHERE
{
  ?item wdt:P31 wd:Q47345468;
    wdt:P361 wd:Q1134303. #Q299823 ATP Tour
  OPTIONAL { ?item wdt:P585 ?y0 . BIND(YEAR(?y0) as ?y) }
  OPTIONAL { ?item wdt:P580 ?start. }
  OPTIONAL { ?item wdt:P582 ?end. }
  OPTIONAL { ?item wdt:P17 ?country. }
  OPTIONAL { ?item wdt:P765 ?surface. }
  OPTIONAL { ?item wdt:P276 ?location. }
  OPTIONAL { ?item p:P2121/psv:P2121 ?st . ?st wikibase:quantityAmount ?prize . OPTIONAL { ?st wikibase:quantityUnit/wdt:P498 ?unit }  } 
  OPTIONAL { ?item wdt:P361 ?partof . FILTER( ?partof != wd:Q1134303)  }
  OPTIONAL { ?item wdt:P31 ?partof2 . FILTER( ?partof2 != wd:Q47345468)  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Click here to launch the Wikidata query

Tournament winners[edit]

SELECT DISTINCT ?edition ?editionLabel ?year ?event ?eventLabel ?winner ?winnerLabel ?participants WHERE {
  ?event wdt:P31   wd:Q46190676 ;
         wdt:P2094 wd:Q16893072 ;
         wdt:P361  ?edition .
  ?edition wdt:P31  wd:Q279800 ;
           wdt:P585 ?pointintime.
  BIND(YEAR(?pointintime) AS ?year)
  OPTIONAL{?event wdt:P1346 ?winner .}
  OPTIONAL{?event wdt:P1132 ?participants .}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ASC(?year)
Click here to launch the Wikidata query

Tennis events in wikidata without winner[edit]

SELECT ?item ?itemLabel ?tournament ?tournamentLabel WHERE {
  ?item wdt:P31 wd:Q46190676 . # Instance of tennis event
  ?item wdt:P2094 wd:Q16893072 . # men's singles
  MINUS
  {
    ?item wdt:P1346 ?winner .
  }
  ?item wdt:P361 ?tournament .
  ?tournament wdt:P361 ?tour .
  ?tour wdt:P3450 ?season_of .
  VALUES ?season_of { wd:Q300008 wd:Q3775082} # ATP World Tour or Grand Prix tennis circuit
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
}
Click here to launch the Wikidata query

Petscan[edit]

American tennis players (category) without a WikiProject Tennis banner[edit]

Petscan link

Wikidata lists[edit]

2018 ATP World Tour tournaments[edit]

Tournament Country City Year Start date End date Edition Category Surface
Qatar Open Qatar Doha 2018 1 January 2018 6 January 2018 26th ATP World Tour 250 series Hard court