Project:SPARQL/examples: Difference between revisions

Line 253: Line 253:
}
}
ORDER BY ?positionLabel ?employerLabel
ORDER BY ?positionLabel ?employerLabel
</sparql>
=== Women and their work activities with dates ===
<sparql tryit="1">
# query for women's work activities with dates
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 bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
SELECT distinct ?personLabel ?work_label ?positionLabel ?date_label ?date
?employerLabel ?organisedLabel ?ofLabel
?s ?person ?work ?position ?employer ?organised ?of
WHERE {
   
  ?person bnwdt:P3 bnwd:Q3 . # women
 
  # get work activities: held position / held position (free text) /  employed as
  ?person ( bnp:P17|bnp:P48|bnp:P105 ) ?s . 
 
  ?person ?work_p ?s . # for activity type label
  ?work wikibase:claim ?work_p;     
        rdfs:label ?work_label. filter(lang(?work_label)="en-gb") . 
   
    # more about the position
    ?s ( bnps:P17|bnps:P48|bnps:P105 ) ?position . 
    # employer / organised by / of (incl free text). TODO: check whether these are mutually exclusive; could make this a union if so.
    OPTIONAL { ?s bnpq:P18 ?employer .} 
    OPTIONAL { ?s bnpq:P109 ?organised .}
    OPTIONAL { ?s ( bnpq:P78 | bnpq:P66 ) ?of .}
  # optional { ?s bnpq:P2 ?location . } # sometimes there is location and no employer/org/of
 
# noted other properties in use for work activities
# facilitated by; seems to be individuals connections rather than orgs.  instance of; doesn't seem very useful
   
  # dates (where available)
    optional {
    ?s ?pq ?date .
     
      ?qual_prop wikibase:qualifier ?pq;     
              #wikibase:propertyType ?date_prop_type; # can check date property types if needed
              wikibase:propertyType wikibase:Time ; # nb that this *does not* include edtf dates but AFAICT there are none in qualifiers.
              rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
      } # /dates
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
 
} # /where
ORDER BY ?person 
</sparql>
</sparql>


586

edits