Project:SPARQL/examples: Difference between revisions

From Beyond Notability
Line 4,299: Line 4,299:


order by ?person ?date_value
order by ?person ?date_value
</sparql>
=== Women who were adults in 1911 ===
<sparql tryit="1">
#title:Women who were adults in 1911 and their calculated ages
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 distinct ?person ?personLabel ?statements ?dob ?dod ?age1911
WHERE {
  ?person bnwdt:P3 bnwd:Q3 ;
        wikibase:statements ?statements .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}
  ?person bnwdt:P26 ?dob . 
  #optional {
      ?person bnwdt:P15 ?dod . 
  #}
 
  filter(year(?dod) > 1911 && year(?dob) <=1893 ) .
  #if dod is made optional a more complex filter to include some women who were likely to still be alive in 1911. but doesnt add very many.
  #filter( ( year(?dob) <= 1893  && year(?dod) > 1911 ) || ( year(?dob) <= 1893 && year(?dob) >1870 ) ) .
 
  #Date literals can be written by adding ^^xsd:dateTime to an ISO 8601 date string: "2012-10-29"^^xsd:dateTime
 
  bind(year("1911-07-01"^^xsd:dateTime) - year(?dob) as ?age1911 ).
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
ORDER BY ?personLabel
</sparql>
</sparql>
661

edits