Project:SPARQL/examples: Difference between revisions

Line 1,128: Line 1,128:
}
}
ORDER BY ?date
ORDER BY ?date
</sparql>
=== All the Things for Organisations ===
<sparql tryit="1">
# Exploratory query to get all info on an item page including qualifiers (but not references) for each organisation in the wikibase
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
?prop ?propLabel ?prop_type
?stmt_value ?stmt_valueLabel
?qual_prop  ?qual_value ?qual_label ?qual_prop_type
?statement
where {
?item bnwdt:P12 bnwd:Q2316  . # instance of organisation
 
  # get all the things about ?item 
    ?item ?p ?statement . 
 
  # to get item Label without using service. couple of missing en-gb labels somewhere
  # ?item rdfs:label ?item_label . filter(lang(?item_label)="en-gb") .
 
 
  # get stuff about ?p
    ?prop wikibase:claim ?p; 
            wikibase:statementProperty ?ps;  # "Links property entity to statement simple value predicate"
        #wikibase:statementValue ?psv; # "Links property entity to statement full value predicate"   
            wikibase:propertyType ?prop_type.       
  # get stuff about ?statement
    ?statement ?ps ?stmt_value.
 
  # get any qualifiers
  optional {
    ?statement ?qual_p ?qual_value . 
    ?qual_prop wikibase:qualifier ?qual_p;
          wikibase:propertyType ?qual_prop_type ;
          rdfs:label ?qual_label. filter(lang(?qual_label)='en-gb') .
    }
 
#  OPTIONAL { ?item skos:altLabel ?alt_label . } 
 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
 
}
order by ?item_label ?prop_label


</sparql>
</sparql>
579

edits