Project:SPARQL/examples: Difference between revisions

From Beyond Notability
No edit summary
Line 946: Line 946:




==Properties==
==Properties, Value Nodes, etc==


===All properties in use in the wikibase with property type, label and description (if present) ===
===All properties in use in the wikibase with property type, label and description (if present) ===
Line 1,053: Line 1,053:


ORDER BY ?personLabel
ORDER BY ?personLabel
</sparql>
=== dates ===
<sparql tryit="1">
## to access the timeValue and timePrecision of a date.
## simple query for a date doesn't differentiate between "1880" and "1 January 1880"; both are returned as 1 January 1880
## there are 14 codes for precision from billion years to second. the ones that might be useful for this project are 7: century, 8: decade, 9: year, 10: month, 11: day
## NB needs bnpsv: prefix
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/>
SELECT DISTINCT ?item ?itemLabel ?date ?precision
WHERE {
  ?item bnp:P26  ?statement. # date of birth (these vary in precision)
  ?statement bnpsv:P26 ?valueNode.
  ?valueNode wikibase:timeValue ?date.
  ?valueNode wikibase:timePrecision ?precision.
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?date


</sparql>
</sparql>
3,427

edits