Project:SPARQL/examples: Difference between revisions

Line 3,538: Line 3,538:
}
}
ORDER BY ?wikidata ?locationLabel
ORDER BY ?wikidata ?locationLabel
</sparql>
=== Archaeological sites that don't have National Heritage England list numbers ===
<sparql tryit="1">
title:archaeological sites with National Heritage numbers
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/>
SELECT ?item ?itemLabel ?location ?locationLabel
(if(bound(?locEngland), "yes", "") as ?inEngland)
WHERE { 
  ?item bnwdt:P12 bnwd:Q86 . # item instance of archaeological site
 
  filter not exists {?item bnwdt:P129 ?thing .  } # without NH list number
 
  optional { ?item bnwdt:P2 ?location .  } # location if it has one
  optional { ?item bnwdt:P2 ?locEngland .
              ?locEngland bnwdt:P33+ bnwd:Q617.
          } # is the location in England
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
order by ?itemLabel


</sparql>
</sparql>
586

edits