Bruger:Dipsacus fullonum/SPARQL

Fra Wikipedia, den frie encyklopædi
Spring til navigation Spring til søgning

Interessante Wikidata-SPARQL-forespørgsler på Wikidata.

Antal biografier på dawiki fordelt efter fødselsår (1800-nu) og køn (linjegraf)[redigér | redigér wikikode]

# Count biographies at dawiki by birth year and sex
#defaultView:LineChart
SELECT ?sex ?birth_year ?articles ?sexLabel
WITH
{
    SELECT ?sex ?birth_year (COUNT(?link) as ?articles)
    WHERE
    {
        ?link schema:about ?person;
              schema:isPartOf <https://da.wikipedia.org/>. hint:Prior hint:runFirst true.
        ?person wdt:P31 wd:Q5.
        ?person p:P569/psv:P569 [
                wikibase:timeValue ?dateOfBirth;
                wikibase:timePrecision ?precision
        ].
        FILTER(?precision >= "8"^^xsd:integer) # Precision is decade or smaller
        BIND(SUBSTR(STR(?dateOfBirth),1,4) as ?birth_year)
        ?person wdt:P21 ?sex.
    }
    GROUP BY ?birth_year ?sex
} AS %results
WHERE
{
    INCLUDE %results.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    FILTER(?birth_year >= "1800")
}
ORDER BY ASC(?birth_year)

Prøv det!

Antal biografier på dawiki fordelt efter fødselsårti (150-nu) og køn (linjegraf)[redigér | redigér wikikode]

# Count biographies at dawiki by birth decade and sex
#defaultView:LineChart
SELECT ?sex ?birth_decade ?articles ?sexLabel
WITH
{
    SELECT ?sex ?birth_decade (COUNT(?link) as ?articles)
    WHERE
    {
        ?link schema:about ?person;
              schema:isPartOf <https://da.wikipedia.org/>. hint:Prior hint:runFirst true.
        ?person wdt:P31 wd:Q5.
        ?person p:P569/psv:P569 [
                wikibase:timeValue ?dateOfBirth;
                wikibase:timePrecision ?precision
        ].
        FILTER(?precision >= "8"^^xsd:integer) # Precision is decade or smaller
        BIND(SUBSTR(STR(?dateOfBirth),1,3) as ?birth_decade)
        ?person wdt:P21 ?sex.
    }
    GROUP BY ?birth_decade ?sex
} AS %results
WHERE
{
    INCLUDE %results.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    FILTER(?birth_decade >= "150")
}
ORDER BY ASC(?birth_decade)

Prøv det!