query-e6001424cd73aa6989f68d349ad8e2cf

rq turtle/ttl

Find all mineral type localities and sort them by most minerals defined (chris.urs-o) SELECT ?locality ?name (COUNT(DISTINCT ?mineral) AS ?count) WHERE { ?mineral wdt:P279* wd:Q7946 . # Find all instances and subclasses of mineral (traverse the tree) ?mineral wdt:P2695 ?locality . # Where a locality statement exists

SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .

}

} GROUP BY ?locality ?name ORDER BY DESC(?count)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Find all mineral type localities and sort them by most minerals defined (chris.urs-o)
SELECT ?locality ?name (COUNT(DISTINCT ?mineral) AS ?count)
WHERE
{
    ?mineral wdt:P279* wd:Q7946 .           # Find all instances and subclasses of mineral (traverse the tree)
    ?mineral wdt:P2695 ?locality .          # Where a locality statement exists

    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .

    }
}
GROUP BY ?locality ?name
ORDER BY DESC(?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?count") v3("?locality"):::projected v2("?mineral"):::projected c5(["bd:serviceParam"]):::iri c7(["en"]):::literal c2(["wd:Q7946"]):::iri v2 --"wdt:P279"--> c2 v2 --"wdt:P2695"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end bind1[/"count(?mineral)"/] v2 --o bind1 bind1 --as--o v4