Project:SPARQL/examples: Difference between revisions

Line 1,552: Line 1,552:


# Exploratory query to get all info on an item page including qualifiers (but not references) for each organisation (Q2316) in the wikibase
# Exploratory query to get all info on an item page including qualifiers (but not references) for each organisation (Q2316) in the wikibase
# As it stands, this *only* fetches organisations that specifically have the instance of Q2316: I didn't realise initially how many organisations don't directly reference Q2316.  
# Initially this *only* fetched organisations that specifically have the instance of Q2316: I didn't realise initially how many organisations don't directly reference Q2316.  
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
Line 1,561: Line 1,561:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


select ?item ?itemLabel  
select distinct ?item ?itemLabel  
?prop ?propLabel ?prop_type
?prop ?propLabel ?prop_type
?stmt_value ?stmt_valueLabel  
?stmt_value ?stmt_valueLabel  
Line 1,569: Line 1,569:
where {
where {


?item bnwdt:P12 bnwd:Q2316  . # instance of organisation
?item bnwdt:P12+ bnwd:Q2316  . # instance of organisation or descendants of (excluding instance of organisation itself)
# ?item ( bnwdt:P12/bnwdt:P12 | bnwdt:P12 ) bnwd:Q2316 . # this line instead would also get organisations whose instance of (eg learned society Q2317) is an instance of Q2316. Or bnwdt:P12* (or bnwdt:P12+) which fetches some extra rows


   # get all the things about ?item   
   # get all the things about ?item   
579

edits