query-717a42edaf27e3af27a12c1e79d75541
22:01, 6 December 2019 (UTC)) talk (MargaretRDonald's used to work. I am hoping it can be made to work again. Thanks, 99of9This query (one of 14:52, 7 December 2019 (UTC)) talk (Larske-- - almost 30 million objects! So it is not much you can do with all these objects in just 60 seconds, just 2 microseconds per object.(Q13442814)scholarly article (P31)instance of : It seems more than 40 percent of Wikidata consists of items that are MargaretRDonald@ - I love that query too. I'd be interested to know what you're using it for. Here's a version that works even with the massive scale of publication data in Wikidata now. You can reduce the LIMIT 300000 if you start getting timeouts.MargaretRDonaldHi
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#>
#defaultView:LineChart
SELECT
?age ?count ?genderLabel
WHERE
{
{ SELECT ?gender ?age (count(*) as ?count) WHERE {
{ SELECT ?gender ?age WHERE {
?author p:P569/psv:P569 ?dob_node . # node for date of birth
?dob_node wikibase:timePrecision "11"^^xsd:integer . # date precision = day
?dob_node wikibase:timeValue ?dob .
?author wdt:P21 ?gender .
?article wdt:P50 ?author .
?article wdt:P31 wd:Q13442814 .
?article wdt:P577 ?date .
FILTER(year(?date)>=2000)
bind( 1000+year(?date)-year(?dob) as ?age_num )
bind( SUBSTR(str(?age_num),1,4) as ?age )
FILTER(BOUND(?age_num))
FILTER(?age_num<=1100)
FILTER(?age_num>=1000)
}
LIMIT 300000
}
} GROUP BY ?gender ?age }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v8("?age"):::projected
v8("?age_num")
v7("?article")
v3("?author")
v9("?count"):::projected
v2("?date")
v5("?dob")
v4("?dob_node")
v6("?gender")
a1((" "))
c7(["11^^xsd:integer"]):::literal
c17(["en"]):::literal
c12(["wd:Q13442814"]):::iri
c15(["bd:serviceParam"]):::iri
f0[["?age_num >= '1000^^xsd:integer'"]]
f0 --> v8
f1[["?age_num <= '1100^^xsd:integer'"]]
f1 --> v8
f2[["bound(?age_num)"]]
f2 --> v8
f3[["year-from-dateTime(?date) >= '2000^^xsd:integer'"]]
f3 --> v2
v3 --"p:P569"--> a1
a1 --"p:statement/value/P569"--> v4
v4 --"wikibase:timePrecision"--> c7
v4 --"wikibase:timeValue"--> v5
v3 --"p:direct/P21"--> v6
v7 --"p:direct/P50"--> v3
v7 --"p:direct/P31"--> c12
v7 --"p:direct/P577"--> v2
bind4[/"'1000^^xsd:integer' + year-from-dateTime(?date) - year-from-dateTime(?dob)"/]
v2 --o bind4
v5 --o bind4
bind4 --as--o v8
bind5[/"substring(str(?age_num),'1^^xsd:integer','4^^xsd:integer')"/]
v8 --o bind5
bind5 --as--o v8
bind7[/"count(*)"/]
bind7 --as--o v9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c15 --"wikibase:language"--> c17
end