Project:SPARQL/examples: Difference between revisions

From Beyond Notability
Line 1,486: Line 1,486:
ORDER BY ?person ?date
ORDER BY ?person ?date


</sparql>
==== Map of Women living in 1890s London ====
<sparql tryit="1">
#title:Women living in 1890s London
# Query for women living in (greater) london in the 1890s
# 1 row per person per address per date, could be reduced to 1 row per person if preferred.
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/>
#defaultView:Map
SELECT distinct ?personLabel ?date_label ?date ?person ?address ?address_item ?londonLabel ?geo ?long ?lat
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . # women
  ?person bnp:P29 ?s .  # resided at
    ?s bnps:P29 ?london .
      ?london bnwdt:P33+ bnwd:Q322 .  # in Q322 greater london.
    # optional street address (text)
  optional {
    ?s bnpq:P31 ?address .
    }
  # optional street address (item)
  optional {
    ?s bnpq:P100 ?address_item .
    }   
  # dates. About 30? not dated.
    #optional {
    ?s ?pq ?date .
    # ?date wikibase:timeValue ?date_value. # if you don't want date label this should work instead
     
      ?qual_prop wikibase:qualifier ?pq;
              wikibase:propertyType wikibase:Time ; # nb excludes edtf dates
              rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
    #  } # /dates
 
    # filter 1890-1899 
  FILTER("1890-01-01"^^xsd:dateTime <= ?date && ?date < "1899-12-31"^^xsd:dateTime).
 
  # address geocoordinates
  optional {
    ?s ?pqq ?geo .
        ?qual_geo wikibase:qualifier ?pqq;
                  wikibase:propertyType wikibase:GlobeCoordinate.
        BIND(geof:longitude(?geo) AS ?long)
        BIND(geof:latitude(?geo)  AS ?lat)
            }
  # todo booth codes
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?person ?date
</sparql>
</sparql>


579

edits