User:Piecesofuk/Wikidata Queries

UK Politicians born on Friday the 13th edit

The following query uses these:

  • Properties: instance of (P31)     , country of citizenship (P27)     , occupation (P106)     , date of birth (P569)     
    # UK Politicians born on Friday the 13th
    SELECT ?item ?itemLabel ?dob WHERE {
     ?item wdt:P31 wd:Q5.
     ?item wdt:P27 wd:Q145.
     ?item wdt:P106 wd:Q82955.
     ?item wdt:P569 ?dob.
    # day of week algorithm from https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Disparate_variation
     BIND(YEAR(?dob) AS ?year)
     BIND(MONTH(?dob) AS ?month)
     BIND(DAY(?dob) AS ?day)
     BIND(FLOOR(?year / 100) AS ?century)
     BIND(REPLACE( STR(?year), "^..", "") AS ?yy)
     BIND( IF (?month <= 2, xsd:integer(?yy) - 1, xsd:integer(?yy)) AS ?yyx)
     BIND( IF (?month <= 2, ?month + 10, ?month - 2) AS ?mm)
     BIND( ?day + FLOOR(2.6 * ?mm - 0.2) + ?yyx + FLOOR(?yyx / 4) + FLOOR(?century / 4) - 2 * ?century AS ?a)
     BIND( ?a - FLOOR(?a / 7) * 7 AS ?mod7)
     # mod7: 0 = Sunday... 6 = Saturday
     FILTER(?day = 13 && ?mod7 = 5)
     SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }
    

Notable Brits without an English Wikipedia page edit

The following query uses these:

  • Properties: instance of (P31)     , country of citizenship (P27)     
    PREFIX schema: <http://schema.org/>
    SELECT ?item ?itemLabel ?numLinks ?who
    WHERE 
    {
      ?item wdt:P31 wd:Q5.   
      ?item wdt:P27 wd:Q145.   # citizen of the UK
      ?item wikibase:sitelinks ?numLinks.
      ?item schema:description ?who.
      FILTER (LANG(?who) = "en") # also must have an English description
      FILTER ( ?numLinks >= 5)
      MINUS {
        ?article schema:about ?item.
        ?article schema:isPartOf <https://en.wikipedia.org/>} # page doesn't exist in English Wikipedia
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    } ORDER BY DESC (?numLinks)
    

People married on Christmas Day edit

The following query uses these:

  • Properties: instance of (P31)     , spouse (P26)     , start time (P580)     
    #People married on Christmas Day
    SELECT ?item ?itemLabel ?dom
    WHERE
    {
     ?item wdt:P31 wd:Q5.
     ?item p:P26 [          # date of marriage is the start time (P580) qualifier to spouse (P26)
       pq:P580 ?dom
     ]
     FILTER (DAY(?dom) = 25 && MONTH(?dom) = 12)
     SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    } ORDER BY ?dom
    

Paintings that depict mammals edit

The following query uses these:

Features: ImageGrid (Q24515278)     

#defaultView:ImageGrid
SELECT ?painting ?paintingLabel ?mammalLabel ?image
WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?painting wdt:P31 wd:Q3305213.
  ?painting wdt:P18 ?image.
  ?painting wdt:P180 ?mammal.
  ?mammal wdt:P171* wd:Q7377     # has a parent taxon of mammal
        }
LIMIT 100

Experimenting with HSV edit

Wikidata SPARQL queries generating visualisations using the HSV colour model