Reputation: 462
Suppose I have the following set of individuals, where some of them have more than one rdfs:label
:
Individual | Label |
---|---|
ind_01 | "ind-001" |
ind_02 | "ind-002" |
ind_02 | "ind-2" |
ind_03 | "label3" |
ind_04 | "ind-4" |
ind_04 | "ind-04" |
... | ... |
I would like to run a SPARQL query that retrieves only one label per individual, no matter which one (i.e., the choice can be totally arbitrary). Thus, a suitable output based on the above dataset would be:
Individual | Label |
---|---|
ind_01 | "ind-001" |
ind_02 | "ind-002" |
ind_03 | "label3" |
ind_04 | "ind-4" |
... | ... |
Upvotes: 0
Views: 224
Reputation: 2285
You could use SAMPLE
, which "returns an arbitrary value from the multiset passed to it".
SELECT ?individual (SAMPLE(?label) AS ?label_sample)
WHERE {
?individual rdfs:label ?label .
}
GROUP BY ?individual
Upvotes: 0