Project:SPARQL/examples: Difference between revisions

From Beyond Notability
(improve labelling of query based on https://beyond-notability.wiki.opencura.com/query/#SELECT%20%3Fa%20%3FaLabel%20%3Fb%20%3Fc%20WHERE%20%7B%0A%20%20%20%20%3Fa%20%3Fb%20%3Fc%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen-gb%22.%20%7D%0A%7D%0ALIMIT%20500)
(add mrs query)
Line 12: Line 12:
   ?elector b:P3 a:Q10 .
   ?elector b:P3 a:Q10 .
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
</sparql>
===People whose name in the records begin with 'Mrs'===
<sparql tryit="1">
SELECT ?id ?name
WHERE { 
  ?id rdfs:label ?name .
  FILTER regex(?name, "mrs *", "i")
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
}
</sparql>
</sparql>

Revision as of 10:04, 14 September 2021

Examples

People whose elections were proposed by men

PREFIX a: <http://beyond-notability.wiki.opencura.com/entity/>
PREFIX b: <http://beyond-notability.wiki.opencura.com/prop/direct/>
SELECT ?personLabel ?persongenderLabel ?electorLabel ?Date
WHERE {  
  ?person b:P7 ?elector ;
          b:P3 ?persongender .
  ?elector b:P3 a:Q10 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}

Try it!


People whose name in the records begin with 'Mrs'

SELECT ?id ?name
WHERE {  
  ?id rdfs:label ?name .
  FILTER regex(?name, "mrs *", "i")
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". } 
}

Try it!