User:Totodu74/Useful queries

From this thread and this page

  • List of taxa described by a given author
SELECT ?taxon ?rankLabel ?taxonLabel ?year
WHERE 
{
  {?taxon wdt:P31 wd:Q16521 } UNION {?taxon wdt:P31 wd:Q310890} UNION {?taxon wdt:P31 wd:Q23038290} UNION {?taxon wdt:P31 wd:Q47487597 } UNION {?taxon wdt:P31 wd:Q98961713} UNION {?taxon wdt:P31 wd:Q2568288} .
  MINUS { ?taxon p:P1403 ?status. }
  ?taxon p:P225 ?name .
  ?taxon wdt:P105 ?rank .
  ?name ps:P225 []; pq:P405 wd:Q21341785 .
  ?name ps:P225 []; pq:P574 ?date .
  BIND(YEAR(?date) AS ?year) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!
  • List of taxa described by scientists from a given institution
SELECT ?taxon ?taxonLabel ?rankLabel ?author ?authorLabel ?year
WHERE 
{
  {?taxon wdt:P31 wd:Q16521 } UNION {?taxon wdt:P31 wd:Q310890} UNION {?taxon wdt:P31 wd:Q23038290} UNION {?taxon wdt:P31 wd:Q47487597 } UNION {?taxon wdt:P31 wd:Q98961713} UNION {?taxon wdt:P31 wd:Q2568288} .
  MINUS { ?taxon p:P1403 ?status. }
  ?taxon p:P225 ?name .
  ?taxon wdt:P105 ?rank .
  ?name ps:P225 []; pq:P405 ?author .
  ?name ps:P225 []; pq:P574 ?date FILTER (?date > "1819-12-31T00:00:00Z"^^xsd:dateTime) .
  BIND(YEAR(?date) AS ?year) .
  {?author wdt:P108 wd:Q663025 } UNION {?author wdt:P937 wd:Q663025} .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!
  • Only the ones with a picture
#defaultView:ImageGrid
SELECT ?taxon ?taxonLabel ?rankLabel ?author ?authorLabel ?year ?image
WHERE 
{
  {?taxon wdt:P31 wd:Q16521 } UNION {?taxon wdt:P31 wd:Q310890} UNION {?taxon wdt:P31 wd:Q23038290} UNION {?taxon wdt:P31 wd:Q47487597 } UNION {?taxon wdt:P31 wd:Q98961713} UNION {?taxon wdt:P31 wd:Q2568288} .
  MINUS { ?taxon p:P1403 ?status. }
  ?taxon p:P225 ?name .
  ?taxon wdt:P105 ?rank .
  ?taxon wdt:P18 ?image .
  ?name ps:P225 []; pq:P405 ?author .
  ?name ps:P225 []; pq:P574 ?date FILTER (?date > "1819-12-31T00:00:00Z"^^xsd:dateTime) .
  BIND(YEAR(?date) AS ?year) .
  {?author wdt:P108 wd:Q663025 } UNION {?author wdt:P937 wd:Q663025} .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!
  • As Bubble charts
#defaultView:BubbleChart
SELECT ?authorLabel (COUNT(?taxon) AS ?count)
WHERE
{
  {?taxon wdt:P31 wd:Q16521 } UNION {?taxon wdt:P31 wd:Q310890} UNION {?taxon wdt:P31 wd:Q23038290} UNION {?taxon wdt:P31 wd:Q47487597 } UNION {?taxon wdt:P31 wd:Q98961713} UNION {?taxon wdt:P31 wd:Q2568288} .
  MINUS { ?taxon p:P1403 ?status. }
  ?taxon p:P225 ?name .
  ?name ps:P225 []; pq:P405 ?author .
  ?name ps:P225 []; pq:P574 ?date FILTER (?date > "1819-12-31T00:00:00Z"^^xsd:dateTime) .
  BIND(YEAR(?date) AS ?year) .
  {?author wdt:P108 wd:Q663025 } UNION {?author wdt:P937 wd:Q663025} .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?authorLabel
ORDER BY (1/ ?count)
Try it!
  • Bar chart displaying the number of taxa described by scientists from a given institution along time
#defaultView:BarChart
SELECT ?year (COUNT(DISTINCT ?taxon) AS ?number_of_new_taxa)
WHERE 
{
  {?taxon wdt:P31 wd:Q16521 } UNION {?taxon wdt:P31 wd:Q310890} UNION {?taxon wdt:P31 wd:Q23038290} UNION {?taxon wdt:P31 wd:Q47487597 } UNION {?taxon wdt:P31 wd:Q98961713} UNION {?taxon wdt:P31 wd:Q2568288} .
  MINUS { ?taxon p:P1403 ?status. }
  ?taxon p:P225 ?name .
  ?name ps:P225 []; pq:P574 ?date FILTER (?date > "1819-12-31T00:00:00Z"^^xsd:dateTime) .
  ?name ps:P225 []; pq:P405 ?author .
  BIND(STR(YEAR(?date)) AS ?year) .
  {?author wdt:P108 wd:Q663025 } UNION {?author wdt:P937 wd:Q663025} .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?year
Try it!
  • Bar chart grouped by decade
#defaultView:BarChart
SELECT (STR(?decade) AS ?decade) (COUNT(DISTINCT ?taxon) AS ?number_of_new_taxa)
WHERE 
{
  {?taxon wdt:P31 wd:Q16521 } UNION {?taxon wdt:P31 wd:Q310890} UNION {?taxon wdt:P31 wd:Q23038290} UNION {?taxon wdt:P31 wd:Q47487597 } UNION {?taxon wdt:P31 wd:Q98961713} UNION {?taxon wdt:P31 wd:Q2568288} .
  MINUS { ?taxon p:P1403 ?status. }
  ?taxon p:P225 ?name .
  ?name ps:P225 []; pq:P574 ?date FILTER (?date > "1819-12-31T00:00:00Z"^^xsd:dateTime) .
  ?name ps:P225 []; pq:P405 ?author .
  {?author wdt:P108 wd:Q663025 } UNION {?author wdt:P937 wd:Q663025} .
  BIND(YEAR(?date) AS ?year)
  BIND(FLOOR(?year / 10) * 10 AS ?decade)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?decade
ORDER BY ?decade
Try it!
  • Bar chart displaying the number of taxa described by scientists from a given institution along time with authors identified (induces duplicates when two persons co-describe the same taxon)
#defaultView:BarChart
SELECT ?year (COUNT(?taxon) AS ?number_of_new_taxa) ?author (SAMPLE(?authorLabel) AS ?authorLabel)
WHERE 
{
  {?taxon wdt:P31 wd:Q16521 } UNION {?taxon wdt:P31 wd:Q310890} UNION {?taxon wdt:P31 wd:Q23038290} UNION {?taxon wdt:P31 wd:Q47487597 } UNION {?taxon wdt:P31 wd:Q98961713} UNION {?taxon wdt:P31 wd:Q2568288} .
  MINUS { ?taxon p:P1403 ?status. }
  ?taxon p:P225 ?name .
  ?name ps:P225 []; pq:P574 ?date FILTER (?date > "1819-12-31T00:00:00Z"^^xsd:dateTime) .
  ?name ps:P225 []; pq:P405 ?author .
  BIND(STR(YEAR(?date)) AS ?year) .
  {?author wdt:P108 wd:Q663025 } UNION {?author wdt:P937 wd:Q663025} .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". 
                         ?author rdfs:label ?authorLabel.}
}
GROUP BY ?year ?author
ORDER BY ?authorLabel
Try it!
  • All articles published in a given journal with no authors
SELECT ?item ?itemLabel ?year
WHERE
{
  ?item wdt:P1433 wd:Q15765167 .
  ?item wdt:P31 wd:Q13442814 .
  optional { ?item wdt:P50 ?author . }
  optional { ?item wdt:P2093 ?authorstring . }
  filter(!bound(?author) && !bound(?authorstring) )
  ?item wdt:P577 ?date .
  BIND(YEAR(?date) AS ?year) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!



Species of beetles with no description in English
SELECT ?taxon ?taxonLabel ?taxonDescription
WHERE 
{
  {?taxon wdt:P31 wd:Q16521 } UNION {?taxon wdt:P31 wd:Q310890} UNION {?taxon wdt:P31 wd:Q23038290} UNION {?taxon wdt:P31 wd:Q47487597 } UNION {?taxon wdt:P31 wd:Q98961713} UNION {?taxon wdt:P31 wd:Q2568288} .
  MINUS { ?taxon p:P1403 ?status. }
  ?taxon p:P225 ?name .
  ?taxon wdt:P105 wd:Q7432 .
  ?taxon wdt:P171* wd:Q22671 .
  FILTER(NOT EXISTS {
    ?taxon schema:description ?taxondesc.
    FILTER(LANG(?taxondesc) = "en")
  })
    
  BIND(YEAR(?date) AS ?year) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?taxon
LIMIT 8000
Try it!


Articles in a given journal with no language precised
SELECT ?item ?itemLabel ?year
WHERE
{
  ?item wdt:P1433 wd:Q21385818 .
  ?item wdt:P31 wd:Q13442814 .
  optional { ?item wdt:P407 ?language . }
  filter(!bound(?language) )
  ?item wdt:P577 ?date .
  BIND(YEAR(?date) AS ?year) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!



Query for Google sheet
SELECT ?taxon ?taxonLabel ?taxonDescription ?rankLabel ?authorLabel ?year ?sourceLabel
WHERE 
{
  {?taxon wdt:P31 wd:Q16521 } UNION {?taxon wdt:P31 wd:Q310890} UNION {?taxon wdt:P31 wd:Q23038290} UNION {?taxon wdt:P31 wd:Q47487597 } UNION {?taxon wdt:P31 wd:Q98961713} UNION {?taxon wdt:P31 wd:Q2568288} .
  MINUS { ?taxon p:P1403 ?status. }
  ?taxon p:P225 ?name .
  ?taxon wdt:P105 ?rank .
  ?name ps:P225 []; pq:P405 ?author .
  {?author wdt:P108 wd:Q663025 } UNION {?author wdt:P937 wd:Q663025} .
  ?name ps:P225 []; pq:P574 ?date FILTER (?date > "1819-12-31T00:00:00Z"^^xsd:dateTime) .
  
  OPTIONAL {
    ?name prov:wasDerivedFrom ?ref .
    ?ref pr:P6184 wd:Q1361864 .
    ?ref pr:P248 ?source .
    }
  
  BIND(YEAR(?date) AS ?year) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?taxon
Try it!