SPARQL examples: Difference between revisions

From Wer Leitet?
(Created page with "==Persons== ===Persons in advisory boards in a time range=== {{SPARQL|query= SELECT DISTINCT ?person ?personLabel ?beirat WHERE { ?person rdfs:label ?personLabel; wdt:P3 wd:Q2; wdt:P463 ?surname; p:P1012 [ps:P1012 ?beirat; pq:P4 ?pubDate]. FILTER((LANG(?personLabel)) = "de") FILTER("1940-01-01"^^xsd:dateTime <= ?pubDate && ?pubDate < "1941-01-01"^^xsd:dateTime). } ORDER BY ?surname }}")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
==Persons==
==Persons==
===Persons ordered by city with additional information if available===
{{SPARQL|query=
SELECT ?city ?person ?personLabel ?birthDate ?birthPlace ?occupation ?mainInfo WHERE {
  ?person rdfs:label ?personLabel;
    wdt:P3 wd:Q2;
OPTIONAL {?person wdt:P381 ?city.}
OPTIONAL {?person wdt:P626 ?birthDate.}
OPTIONAL {?person wdt:P349 ?birthPlace.}
OPTIONAL {?person wdt:P999 ?occupation.}
OPTIONAL {?person wdt:P253 ?mainInfo.}
FILTER((LANG(?personLabel)) = "de")
} ORDER BY ?city
}}


===Persons in advisory boards in a time range===
===Persons in advisory boards in a time range===
Line 13: Line 27:
FILTER("1940-01-01"^^xsd:dateTime <= ?pubDate && ?pubDate < "1941-01-01"^^xsd:dateTime).
FILTER("1940-01-01"^^xsd:dateTime <= ?pubDate && ?pubDate < "1941-01-01"^^xsd:dateTime).
} ORDER BY ?surname
} ORDER BY ?surname
}}
===Count of occupations===
{{SPARQL|query=
SELECT DISTINCT (COUNT (?person) as ?noPeople) ?occupation WHERE {
?person wdt:P3 wd:Q2;
            wdt:P999 ?occupation.
}
GROUP BY ?occupation HAVING (?noPeople  > 1)
ORDER BY DESC(?noPeople)
}}
}}

Latest revision as of 14:12, 5 August 2024

Persons

Persons ordered by city with additional information if available

SELECT ?city ?person ?personLabel ?birthDate ?birthPlace ?occupation ?mainInfo WHERE {
  ?person rdfs:label ?personLabel;
     wdt:P3 wd:Q2; 
OPTIONAL {?person wdt:P381 ?city.}
OPTIONAL {?person wdt:P626 ?birthDate.}
OPTIONAL {?person wdt:P349 ?birthPlace.}
OPTIONAL {?person wdt:P999 ?occupation.}
OPTIONAL {?person wdt:P253 ?mainInfo.}
FILTER((LANG(?personLabel)) = "de")
} ORDER BY ?city

Persons in advisory boards in a time range

SELECT DISTINCT ?person ?personLabel ?beirat WHERE {
  ?person rdfs:label ?personLabel;
     wdt:P3 wd:Q2; 
     wdt:P463 ?surname;
     p:P1012 [ps:P1012 ?beirat;
              pq:P4 ?pubDate].
FILTER((LANG(?personLabel)) = "de")
FILTER("1940-01-01"^^xsd:dateTime <= ?pubDate && ?pubDate < "1941-01-01"^^xsd:dateTime).
} ORDER BY ?surname

Count of occupations

SELECT DISTINCT (COUNT (?person) as ?noPeople) ?occupation WHERE {
 ?person wdt:P3 wd:Q2;
             wdt:P999 ?occupation.
 }
GROUP BY ?occupation HAVING (?noPeople  > 1)
ORDER BY DESC(?noPeople)