query-a128a37d841e7216c30657b486b87520

rq turtle/ttl

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

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)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?_anon_42b5416610844a34809f33a099ae9de127494") v11("?avgAge"):::projected v10("?avgBirthYear"):::projected v5("?birth") v7("?birthYear") v10("?count"):::projected v6("?death") v8("?deathYear") v4("?occ"):::projected v3("?p") a2((" ")) a1((" ")) a4((" ")) a3((" ")) c15(["fr"]):::literal c13(["bd:serviceParam"]):::iri c3(["wd:Q5"]):::iri c6(["9^^xsd:integer"]):::literal f0[["?count > '300^^xsd:integer'"]] f0 --> v10 v3 --"p:direct/P31"--> c3 v3 --"p:direct/P106"--> v4 a1 --"wikibase:timePrecision"--> c6 a1 --"wikibase:timeValue"--> v5 v3 --"p:P569"--> a2 a2 --"p:statement/value/P569"--> a1 a3 --"wikibase:timePrecision"--> c6 a3 --"wikibase:timeValue"--> v6 v3 --"p:P570"--> a4 a4 --"p:statement/value/P570"--> a3 bind3[/"average(year-from-dateTime(?birth))"/] v5 --o bind3 bind3 --as--o v7 bind4[/"average(year-from-dateTime(?death))"/] v6 --o bind4 bind4 --as--o v8 bind8[/"average(?birthYear)"/] v7 --o bind8 bind8 --as--o v9 bind9[/"count(?p)"/] v3 --o bind9 bind9 --as--o v10 bind10[/"numeric-round()"/] null --o bind10 bind10 --as--o v10 bind11[/"average(?deathYear - ?birthYear)"/] v8 --o bind11 v7 --o bind11 bind11 --as--o v11 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end