query-a128a37d841e7216c30657b486b87520
Durée de vie moyenne par profession ayant plus de 300 éléments recensés SELECT ?occ ?occLabel ?avgAge ?avgBirthYear ?count WHERE { {
groupe de personne avec leur âge et profession
SELECT ?occ (count(?p) as ?count) (round(avg(?birthYear)) as ?avgBirthYear) (avg(?deathYear - ?birthYear) as ?avgAge) WHERE { {
personnes avec Get people with occupation + birth/death dates; combine multiple birth/death dates using avg
SELECT ?p ?occ (avg(year(?birth)) as ?birthYear) (avg(year(?death)) as ?deathYear) WHERE { ?p wdt:P31 wd:Q5 ; wdt:P106 ?occ ; p:P569/psv:P569 [ wikibase:timePrecision "9"^^xsd:integer ; # precision of at least year wikibase:timeValue ?birth ; ] ; p:P570/psv:P570 [ wikibase:timePrecision "9"^^xsd:integer ; # precision of at least year wikibase:timeValue ?death ; ] . } GROUP BY ?p ?occ } } GROUP BY ?occ LIMIT 200 }
FILTER (?count > 300) # professions recensant plus de 300 éléments SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" . } } ORDER BY ASC(?avgAge)
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Durée de vie moyenne par profession ayant plus de 300 éléments recensés
SELECT ?occ ?occLabel ?avgAge ?avgBirthYear ?count
WHERE
{
{
# groupe de personne avec leur âge et profession
SELECT
?occ
(count(?p) as ?count)
(round(avg(?birthYear)) as ?avgBirthYear)
(avg(?deathYear - ?birthYear) as ?avgAge)
WHERE {
{
# personnes avec Get people with occupation + birth/death dates; combine multiple birth/death dates using avg
SELECT
?p
?occ
(avg(year(?birth)) as ?birthYear)
(avg(year(?death)) as ?deathYear)
WHERE {
?p wdt:P31 wd:Q5 ;
wdt:P106 ?occ ;
p:P569/psv:P569 [
wikibase:timePrecision "9"^^xsd:integer ; # precision of at least year
wikibase:timeValue ?birth ;
] ;
p:P570/psv:P570 [
wikibase:timePrecision "9"^^xsd:integer ; # precision of at least year
wikibase:timeValue ?death ;
] .
}
GROUP BY ?p ?occ
}
}
GROUP BY ?occ
LIMIT 200
}
FILTER (?count > 300) # professions recensant plus de 300 éléments
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" . }
}
ORDER BY ASC(?avgAge)