Project:SPARQL/examples: Difference between revisions

Line 1,117: Line 1,117:
GROUP BY ?value ?valueLabel
GROUP BY ?value ?valueLabel


ORDER BY lcase(?valueLabel) # order by is case sensitive grrrrrrr
ORDER BY lcase(?valueLabel) # order by is case sensitive
# or to order by count
# or to order by count
# order by ?count
# order by ?count
</sparql>
=== Fetch any of multiple types of EDTF date for a woman ===
<sparql tryit="1">
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  ?person ?personLabel ?date_edtf ?date_type
WHERE { ?person bnwdt:P3 bnwd:Q3 .
      FILTER NOT EXISTS { ?person bnwdt:P4 bnwd:Q12 . }
     
      ## short form of UNION using |
      ?person ( bnwdt:P131 | bnwdt:P132 | bnwdt:P133  ) ?date_edtf .
## full length UNION version
## {?person bnwdt:P131 ?date_edtf } union {?person bnwdt:P132 ?date_edtf } union {?person bnwdt:P133 ?date_edtf } 
   
      ?person ?date_type ?date_edtf .
     
      # filter is important for edtf dates! https://github.com/ProfessionalWiki/WikibaseEdtf
      FILTER ( datatype(?date_edtf) = xsd:edtf  ) .
           
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
    }
ORDER BY ?personLabel


</sparql>
</sparql>
579

edits