query-9361061c1cc7d4152e2b4a2775a5c73a
How to remove duplicate query results (based on the values of the results)?Sorry, if this is a too basic question of SPARQL, but how to remove the duplicate of Maria Callas (in results) who has two different images. I would like to remove the 2nd one. Many thanks!
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
select DISTINCT ?entity ?entityLabel ?starttime ?endtime ?image
where
{
?entity wdt:P31 wd:Q5 .
?entity p:P551 ?statement .
?statement ps:P551 wd:Q90 .
OPTIONAL {?statement pq:P580 ?starttime . }
OPTIONAL {?statement pq:P582 ?endtime . }
OPTIONAL { ?entity wdt:P18 ?image . }
FILTER((?starttime <= "1977-09-01"^^xsd:date && "1977-10-01"^^xsd:date <= ?endtime) || ("1977-09-01"^^xsd:date <= ?starttime && ?starttime <= "1977-10-01"^^xsd:dat) || ("1977-09-01"^^xsd:date <= ?endtime && ?endtime <= "1977-10-01"^^xsd:dat))
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?starttime
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?endtime"):::projected
v3("?entity"):::projected
v5("?image"):::projected
v1("?starttime"):::projected
v4("?statement")
c8(["wd:Q90"]):::iri
c15(["en"]):::literal
c13(["bd:serviceParam"]):::iri
c5(["wd:Q5"]):::iri
f0[["(?starttime <= '1977-09-01^^xsd:date''1977-10-01^^xsd:date' <= ?endtime || ('1977-09-01^^xsd:date' <= ?starttime?starttime <= s1977-10-01^^<http://www.w3.org/2001/XMLSchema#dat>' || '1977-09-01^^xsd:date' <= ?endtime?endtime <= s1977-10-01^^<http://www.w3.org/2001/XMLSchema#dat>'))"]]
f0 --> v1
f0 --> v2
v3 --"p:direct/P31"--> c5
v3 --"p:P551"--> v4
v4 --"p:statement/P551"--> c8
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:qualifier/P580".-> v1
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:qualifier/P582".-> v2
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P18".-> v5
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c13 --"wikibase:language"--> c15
end