I'm trying to query DBPedia for a list of properties relating to a given class in the ontology, but since the human-readable "labels" aren't always clear, I'd also like to provide an example from the database. The problem is that while I want to select all distinct properties, I only want a single example of each property. Here's how my query looks without capturing the example:
SELECT DISTINCT ?prop ?title WHERE {
?thing ?prop [].
?thing a <http://dbpedia.org/ontology/Currency>.
?prop rdf:type rdf:Property.
?prop rdfs:label ?title.
} ORDER BY DESC(COUNT(DISTINCT ?thing))
LIMIT 100
If I change it in this way, I start getting duplicate values for ?prop:
SELECT DISTINCT ?prop ?title ?example WHERE {
?thing ?prop ?example.
?thing a <http://dbpedia.org/ontology/Currency>.
?prop rdf:type rdf:Property.
?prop rdfs:label ?title.
} ORDER BY DESC(COUNT(DISTINCT ?thing))
LIMIT 100
I'm very new to using SPARQL and database queries in general, so it's not at all clear to me how to do this. Ideally, I'd have something like DISTINCT(?prop) ?title ?example, which selects every unique value for prop, and returns its title and an example.