Project:SPARQL/examples: Difference between revisions

Line 2,253: Line 2,253:
order by ?personLabel ?date ?placeLabel
order by ?personLabel ?date ?placeLabel


</sparql>
=== Wikidata categories for BN instance of locality in the UK ===
<sparql tryit="1">
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
#title: counts of WD instance of (P31) for BN localities (instance of Q2147) in the UK
select ?wd_io ?wd_io_label  (count(*) as ?count)
where {
  ?item bnwdt:P12 bnwd:Q2147 . # BN io locality
  ?item bnwdt:P33* bnwd:Q1741 . # in UK
 
  ?item bnwdt:P117 ?wd.
      bind(iri(concat("http://www.wikidata.org/entity/", str(?wd))) as ?wikidata) .
      SERVICE <https://query.wikidata.org/sparql> { 
          ?wikidata wdt:P31 ?wd_io.
              ## p31 Q48091 region of england.
            SERVICE wikibase:label { bd:serviceParam wikibase:language "en". 
                                    ?wikidata rdfs:label ?wd_label .
                                    ?wd_io rdfs:label ?wd_io_label .
                                  }       
        }
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
group by ?wd_io ?wd_io_label
order by ?wd_io_label
</sparql>
</sparql>


579

edits