Marius Lian
Marius Lian

Reputation: 543

In DBPedia get number of subjects having a property

I'd like to know the number of subjects having a certain property.

For instance I'd like to know how many subjects having the trainer property: http://dbpedia.org/ontology/trainer

A somewhat related answer is this: https://stackoverflow.com/a/21729888/1680130

There I can change the query to get a list of subjects for a single property. But I simply would like to have a count of the subjects for the given property.

Upvotes: 0

Views: 87

Answers (1)

Joshua Taylor
Joshua Taylor

Reputation: 85883

This is a pretty simple query. You want to use the count aggregate mentioned in §11 Aggregates, and described in more detail in §18.5.1.2 Count.

select (count(distinct ?s) as ?nThingsWithTrainer) {
  ?s dbpedia-owl:trainer []
}

SPARQL Results

In general, it's a good idea to at least skim over the standard, SPARQL 1.1 Query Language. You don't need to memorize every bit of it, but if you take a glance at it, you'll see lots of examples, and you'll have a good idea what's actually in the language, and know where to look.

Upvotes: 4

Related Questions