我正在尝试编写一个查询,告诉我国家元首首次就职的年龄。我无法从正确的
start time
语句中获取 position held
限定符。
这是我正在使用的:
SELECT DISTINCT ?headOfState ?headOfStateLabel ?age ?countryLabel ?positionLabel
{
# find heads of state positions
hint:Query hint:optimizer "None".
?position wdt:P279* wd:Q48352 .
# sovereign states only
?position wdt:P1001 ?country .
?country wdt:P31 wd:Q3624078 .
# fetch names of officeholders
?headOfState wdt:P39 ?position .
# dates
?headOfState p:P39 ?statement .
?statement ps:P39 ?position .
?statement pq:P580 ?termStart. hint:Prior hint:rangeSafe true.
?headOfState wdt:P569 ?dob. hint:Prior hint:rangeSafe true.
BIND(MIN(YEAR(?termStart))-YEAR(?dob) as ?age)
FILTER("1950-01-01"^^xsd:dateTime <= ?termStart && ?termStart < "1980-01-01"^^xsd:dateTime)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY DESC(?age)
这里可能存在我不认识的错误。但举个我确实认识到的例子:它返回 Anwar Sadat 在 32 岁时成为埃及总统。萨达特的出生日期是 1918 年,并且没有开始时间为 1950 年的
position held
。那么数字在哪里32来自哪里?
我正在查看您的问题,奇怪的是,当
?age
和 ?termStart
也添加到 ?dob
语句中时,查询会返回不同的 SELECT
值。
无论如何,问题是您在查询正文中使用
MIN()
。