query-186e5c8cdf9324ff5230d64134aa6bf8

rq turtle/ttl

CountHello. You helped me with this query.

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#>
SELECT ?gn ?gnLabel ?gnDescription ?ws ?nl (COUNT(?item) as ?count) (SAMPLE(?item) as ?sample) (SAMPLE(?itemLabel) as ?sampleLabel) 
{
    VALUES ?countries { wd:Q229 wd:Q41 wd:Q15240466 }
    ?item wdt:P27 wd:Q229 .
    ?item wdt:P31 wd:Q5 .
    ?item wdt:P735 ?gn .
    OPTIONAL { ?gn wdt:P1705 ?nl }
    OPTIONAL { ?gn wdt:P282 / wdt:P506 ?ws }  
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?gn ?gnLabel ?gnDescription ?ws ?nl
ORDER BY DESC(?count) ?gn ?ws

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?count") v4("?countries") v2("?gn"):::projected v5("?item"):::projected v7("?itemLabel"):::projected v6("?nl"):::projected v8("?sample") v9("?sampleLabel") v3("?ws"):::projected a1((" ")) c10(["bd:serviceParam"]):::iri c2(["wd:Q229"]):::iri c4(["wd:Q5"]):::iri c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal bind0[/VALUES ?countries/] bind0-->v4 bind00(["wd:Q229"]) bind00 --> bind0 bind01(["wd:Q41"]) bind01 --> bind0 bind02(["wd:Q15240466"]) bind02 --> bind0 v5 --"wdt:P27"--> c2 v5 --"wdt:P31"--> c4 v5 --"wdt:P735"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P1705".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P282".-> a1 a1 --"wdt:P506"--> v3 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind4[/"count(?item)"/] v5 --o bind4 bind4 --as--o v8 bind5[/"sample(?item)"/] v5 --o bind5 bind5 --as--o v8 bind6[/"sample(?itemLabel)"/] v7 --o bind6 bind6 --as--o v9