query-0e9b194a484a2708a7c1de0dd04ca1a2

rq turtle/ttl

Find all mineral type localities and sort them by most minerals defined SELECT ?locality ?name (COUNT(DISTINCT ?mineral) AS ?count) WHERE { ?mineral wdt:P579 ?status . ?mineral wdt:P2695 ?locality . # Where a locality statement exists

SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
    ?locality rdfs:label ?name
}

} 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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Find all mineral type localities and sort them by most minerals defined
SELECT ?locality ?name (COUNT(DISTINCT ?mineral) AS ?count)
WHERE
{
    ?mineral wdt:P579 ?status .
    ?mineral wdt:P2695 ?locality .          # Where a locality statement exists

    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
        ?locality rdfs:label ?name
    }
}
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; v6("?count") v4("?locality"):::projected v2("?mineral"):::projected v5("?name"):::projected v3("?status") c4(["bd:serviceParam"]):::iri c6(["en"]):::literal v2 --"wdt:P579"--> v3 v2 --"wdt:P2695"--> v4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c4 --"wikibase:language"--> c6 v4 --"rdfs:label"--> v5 end bind1[/"count(?mineral)"/] v2 --o bind1 bind1 --as--o v6