query-76ba04f4815e8e79a93e300d96082c96

rq turtle/ttl

Who are things in Hungary named after in descending order SELECT ?nameSake ?nameSakeLabel ?count WHERE { { SELECT ?nameSake (COUNT(?item) AS ?count) WHERE { { ?item wdt:P131* wd:Q28 . } UNION { ?item wdt:P17 wd:Q28 . } ?item wdt:P138 ?nameSake . } GROUP BY ?nameSake } SERVICE wikibase:label { bd:serviceParam wikibase:language "hu,en" } } 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#>
# Who are things in Hungary named after in descending order
SELECT ?nameSake ?nameSakeLabel ?count
WHERE
{
  {
    SELECT ?nameSake (COUNT(?item) AS ?count)
    WHERE
    {
        {
          ?item wdt:P131* wd:Q28 .
        }
        UNION
        {
          ?item wdt:P17 wd:Q28 .
        }
        ?item wdt:P138 ?nameSake .
    }
    GROUP BY ?nameSake
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "hu,en" }
}
ORDER BY DESC (?count)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?count"):::projected v2("?item") v3("?nameSake"):::projected c2(["wd:Q28"]):::iri c6(["bd:serviceParam"]):::iri c8(["hu,en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P17"--> c2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P131"--> c2 end union0r <== or ==> union0l end v2 --"wdt:P138"--> v3 bind1[/"count(?item)"/] v2 --o bind1 bind1 --as--o v4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end