问题:大家好。我从Wikidata示例页面中找到了示例脚本, 但结果是,每种情况只显示一个参与者,而大多数情况下有很多参与者。有没有办法显示所有参与者的标签?我不明白为什么(和如何)只选择一个出现。
SELECT distinct ?race ?raceLabel ?musherLabel
WHERE
{
{ ?race wdt:P31/wdt:P279* wd:Q1968664 . }
UNION { ?race wdt:P31/wdt:P641* wd:Q1968664 . }
?race p:P710 ?musherS . #here we have a full statement, not a value
?musherS ps:P710 ?musher . #here we get the value
FILTER NOT EXISTS { ?musherS pq:P1352 ?rank }
FILTER NOT EXISTS { ?musherS pq:P793 ?event }
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" }
}
ORDER BY ?raceLabel
编辑:
在这里(https://www.wikidata.org/wiki/Help:Qualifiers)我读到:
获取多个值
由一个属性的多个值组成的语句示例 Wikidata允许项目每个属性具有多个值。对于某些陈述(例如某个人的孩子或某个国家的官方语言),拥有多个可能没有任何限定的值是完全合理的。
但是,当属性实际上只需要一个值时,项也可能具有带有多个值的语句。当一个项目在理想情况下仅应具有一个值(例如,一个城市的人口)但具有多个值时,则应使用限定符以指示有关该值的更多信息,例如这些值的日期,来源,方式确定,他们确切指的是什么,等等。
那么这是否意味着没有办法完全获得它们(标签值)?
答案 0 :(得分:1)
对于每个种族单行,您必须结合使用group by
和聚合函数group_concat
。
SELECT distinct ?race ?raceLabel (group_concat(?musherLabel; separator="; ") as ?mushers)
WHERE
{
{ ?race wdt:P31/wdt:P279* wd:Q1968664 . }
UNION
{ ?race wdt:P31/wdt:P641* wd:Q1968664 . }
?race p:P710 ?musherS . #here we have a full statement, not a value
?musherS ps:P710 ?musher . #here we get the value
FILTER NOT EXISTS { ?musherS pq:P1352 ?rank }
FILTER NOT EXISTS { ?musherS pq:P793 ?event }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
?musher rdfs:label ?musherLabel .
?race rdfs:label ?raceLabel .
}
}
GROUP BY ?race ?raceLabel
ORDER BY ?raceLabel
+------------------------------------------+--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| race | raceLabel | mushers |
+------------------------------------------+--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| http://www.wikidata.org/entity/Q19361352 | Q19361352 | Brett Bruggeman; Brett Bruggeman; Brett Bruggeman; Brett Bruggeman; Bryce Mumford; Bryce Mumford; Bryce Mumford; Bryce Mumford |
| http://www.wikidata.org/entity/Q18577453 | 1993 Iditarod | Beverly Masek |
| http://www.wikidata.org/entity/Q18577456 | 1996 Iditarod | Rick Swenson |
| http://www.wikidata.org/entity/Q23014078 | 2016 Iditarod | Robert Redington; Hans Gatt; Anna Berington; DeeDee Jonrowe; Noah Burmeister; Ed Stielstra; Ken Anderson; Tim Pappas; Ellen Halverson; Jodi Bailey; Jeff King; Brent Sass; Becca Moore; Robert Bundtzen; Karin Hendrickson; Sigrid Ekran; Melissa Owens; Rob Cooke; Scott Smith; Kim Franklin; Elliot Anderson; Scott Janssen; Paige Drobny; Ketil Reitan; Justin Savidis; Aliy Zirkle; Cim Smyth; Dag Torulf Olsen; Linwood Fiedler; Kristin Bacon; Monica Zappa; Billy Snodgrass; Tore Albrigtsen; Mats Pettersson; Kristin Knight Pace; Cindy Gallea; Ray Redington; Katherine Keith; James Volek; Joar Leifseth Ulsom; Jim Lanier; Martin Koenig; Ryne Olson; Nathan Schroeder; Hugh Neff; Tom Jamgochian; Larry Daugherty; Lisbet Norris; Zoya DeNure; Ralph Johannesen; Allen Moore; Michael Williams; Sarah Stokey; Rick Casillo; John Baker; Paul Gebhardt; Dallas Seavey; Mary Helwig; Michelle Phillips; Martin Buser; Kristy Berington; Jan Steves; Ryan Redington; Trent Herbst; Jason Campeau; Alan Eischens; Mitch Seavey; Wade Marrs; Richie Diehl; Nicolas Petit; Charley Bejna; Patrick Beall; Lance Mackey; Robert Sørlie; Jessie Royer; Miriam Osredkar; Kelly Maixner; Noah Pereira; Travis Beals; Geir Idar Hjelvik; Matthew Failor; Peter Kaiser; Lars Monsen; Jason Mackey; Cody Strathe |
| http://www.wikidata.org/entity/Q22093610 | 2016 Kuskokwim 300 | Pato Geron |
+------------------------------------------+--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+