提问人:xhgf5 提问时间:10/20/2023 最后编辑:xhgf5 更新时间:11/8/2023 访问量:54
具有相同实体的 UNION 输出和缺失值的 SPARQL 查询 - 如何仅输出可用值?
SPARQL query with UNION outputs available and missing values for the same entities - How to output only the available values?
问:
此查询输出孪生体。为此,它使用 UNION 组合了以下项目集:
- 作为“Twin”类实例的实体
- 有同日出生的亲生兄弟姐妹的实体
我的问题是,符合这两个条件的人在结果列表中出现了两次。例如 #31 和 #32(丹麦的约瑟芬公主)。我如何使它,如果有 和 的可用值,它们将被输出,而不是具有值“”的版本?
这些缺失值应该只输出给像 #11 (Mario Andretti) 这样的人,他们是“双胞胎”,但缺少双胞胎兄弟姐妹信息。我尝试使用但没有运气。我还尝试在 WDQS 中运行它,但即使我剥离了查询的大部分部分,我也会得到超时。?twin_2_name
?twin_2_desc
-
BIND(COALESCE(...))
如果链接再次损坏/错误,则查询文本:
SELECT DISTINCT ?twin_name ?twin_desc ?date_birth ?twin_2_name ?twin_2_desc
WHERE
{ { ?twin wdt:P31/(wdt:P279)* wd:Q159979 .
?twin wdt:P569 ?date_birth
}
UNION
{ { { ?twin p:P569 ?p569 .
?p569 rdf:type wikibase:BestRank ;
psv:P569 ?psv569 .
?psv569 wikibase:timePrecision ?time_precision
}
FILTER ( ?time_precision >= 11 )
?psv569 wikibase:timeValue ?date_birth
{ ?twin wdt:P25 ?mother }
UNION
{ ?twin ^wdt:P40 ?mother .
?mother wdt:P21 wd:Q6581072
}
?mother wdt:P40 ?twin_2 .
?twin_2 wdt:P569 ?date_birth
}
FILTER ( ?twin != ?twin_2 )
?twin_2 rdfs:label ?twin_2_name
FILTER ( lang(?twin_2_name) = "en" )
?twin_2 schema:description ?twin_2_desc
FILTER ( lang(?twin_2_desc) = "en" )
}
?twin schema:description ?twin_desc
FILTER ( lang(?twin_desc) = "en" )
?twin rdfs:label ?twin_name
FILTER ( lang(?twin_name) = "en" )
?twin ^schema:about/wikibase:sitelinks ?sitelinks
}
ORDER BY DESC(?sitelinks)
答: 暂无答案
评论