Project:SPARQL/examples: Difference between revisions

Line 1,485: Line 1,485:


<sparql tryit="1">
<sparql tryit="1">
# Query to look for uses of <unknown value>
# Query to look for uses of <unknown value> (now including qualifiers)


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,495: Line 1,495:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT distinct  ?name ?unknown_value_for ?type ?item
SELECT distinct  ?item ?itemLabel ?stmtLabel ?sub_Label ?unknown_value_forLabel  ?unknown_value_for
WHERE
WHERE
{
{
?item ?p ?s.
{
  # top level items
  ?item ?p ?s.
  ?s ?sub ?sub_ .
  ?stmt wikibase:claim ?p.
  ?stmt wikibase:statementProperty ?sub. 
  ?s ?pq ?pq_ .
  ?unknown_value_for wikibase:qualifier ?pq . 
  FILTER( isBLANK(?pq_)  ) .
  }
  UNION
  {
  # qualifiers
  ?item ?p ?statement.
 
 
  FILTER isBLANK(?s) . # get ?s that are <unknown value>
  ?statement ?ps ?ps_ .
 
  ?unknown_value_for wikibase:claim ?p.
  ?unknown_value_for wikibase:statementProperty ?ps.
    
    
  ?item rdfs:label ?name. filter(lang(?name)= "en-gb") .  
  FILTER( isBLANK(?ps_) ) .
   
  }
    ?prop wikibase:directClaim ?p.
 
    ?prop wikibase:propertyType ?type. 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
    ?prop rdfs:label ?unknown_value_for. filter(lang(?unknown_value_for)= "en-gb") . 


}
}
order by ?unknown_value_for ?name
 
ORDER BY ?itemLabel ?unknown_value_forLabel
</sparql>
</sparql>
579

edits