query-7fed1d26faec90a92b3024250cc449cf

rq turtle/ttl

TODO

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?count_linked_items (COUNT(?count_linked_items) as ?count_rivers_with_this_many_linked_items) WHERE
{
   {
  SELECT ?river (COUNT(?item) as ?count_linked_items) WHERE {    # river, how many items link to the river
     {
  SELECT ?river WHERE {
   ?river wdt:P131/wdt:P131 wd:Q22 .             # get things in Scotland
    } }    ?river wdt:P31/wdt:P279* wd:Q55659167.       # ensure it is a watercourse

    ?item ?predicate ?river .                    # something links to it
    ?property wikibase:directClaim ?predicate .  # using a wdt: predicate
    } GROUP BY ?river }} GROUP BY ?count_linked_items ORDER BY DESC(?count_linked_items)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?count_linked_items"):::projected v6("?count_rivers_with_this_many_linked_items") v3("?item") v4("?predicate") v5("?property") v2("?river") a1((" ")) a2((" ")) c5(["wd:Q55659167"]):::iri c2(["wd:Q22"]):::iri v2 --"wdt:P131"--> a1 a1 --"wdt:P131"--> c2 v2 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c5 v3 -->v4--> v2 v5 --"wikibase:directClaim"--> v4 bind1[/"count(?item)"/] v3 --o bind1 bind1 --as--o v6 bind3[/"count(?count_linked_items)"/] v6 --o bind3 bind3 --as--o v6