query-5f9fd7cbcda03b43e9ca92d37e4d7b6e

rq turtle/ttl

Countries of External Identifiers for Items with CBDB ID

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?ExternalIdentifierProperty ?ExternalIdentifierPropertyLabel ?countryorregionLabel WHERE {
    {
        SELECT ?ExternalIdentifierProperty (COUNT(DISTINCT ?item) AS ?count) WHERE {


           ?item wdt:P497 ?cbdb_id .
           ?item ?p ?id .
           ?ExternalIdentifierProperty wikibase:directClaim ?p; wikibase:propertyType wikibase:ExternalId.     
        }  GROUP BY ?ExternalIdentifierProperty
    }
    OPTIONAL {?ExternalIdentifierProperty wdt:P17 ?countryorregion.}
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
    }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?ExternalIdentifierProperty"):::projected v2("?cbdb_id") v6("?count") v7("?countryorregion") v4("?id") v1("?item") v3("?p") c7(["bd:serviceParam"]):::iri c9(["en"]):::literal c4(["wikibase:ExternalId"]):::iri v1 --"wdt:P497"--> v2 v1 -->v3--> v4 v5 --"wikibase:directClaim"--> v3 v5 --"wikibase:propertyType"--> c4 bind1[/"count(?item)"/] v1 --o bind1 bind1 --as--o v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v5 -."wdt:P17".-> v7 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end