我的问题很简单。但是我无法掌握如何使用SParqL进行操作。
我有一个日期列表(格式YYYY-mm-dd
)。对于每个日期,我都创建了一个Event
(schema:PublicationEvent
)。当Photos
和Event
相等时,photo-date
链接到该event-date
。现在,我想列出每年一次并且每年只显示一张照片。在我目前的查询中,我每年获得多张照片。我想每年有一张照片。有人可以帮我吗?
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX spif: <http://spinrdf.org/spif#>
select distinct ?newDate (count(?photoRef) as ?photoCount)
from <http://archief.nl/events/Graph:anpGebeurtenissen>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX spif: <http://spinrdf.org/spif#>
select distinct ?newDate (count(?photoRef) as ?photoCount)
from <http://archief.nl/events/Graph:anpGebeurtenissen>
where {
?dateEventuri a schema:PublicationEvent;
rdfs:label ?dateEventLabel;
schema:image ?photoRef.
bind(substr(?dateEventLabel,"1","4") as ?newDate)
}
group by ?newDate ?photoRef
order by ?newDate
结果是这样的。对于1937年,显示的照片有3个URI。但是,我每年希望看一张照片(uri)。
1 1937 http://test.nl/NL/doc/PhotoReference:A8BD26A2D0B4102DBCF8003048976D84
2 1937 http://test.nl/NL/doc/PhotoReference:AF33B3B6D0B4102DBCF8003048976D84
3 1937 http://test.nl/NL/doc/PhotoReference:AF33B906D0B4102DBCF8003048976D84
4 1938 http://test.nl/NL/doc/PhotoReference:AEC963E4D0B4102DBCF8003048976D84
5 1938 http://test.nl/NL/doc/PhotoReference:AEC964A2D0B4102DBCF8003048976D84