query-0a6179e690a052035e4812db5a566b87
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?property ?propertyLabel ?count # group on ?property so that we can count the number of distinct items with this property
WHERE
{
{
# Using a named subquery here so that we can keep the label service away from the part of the query
# which is looking at the items: prevents the label service slowing down the report by getting labels for each
# item when we don't ever want to see the item labels
SELECT ?property (count(distinct ?item) as ?count) WHERE {
?item wdt:P31 wd:Q23397 . # It's a lake
# Run the above statement first
?item wdt:P17 wd:Q145 . # It's in the UK
?item ?predicate ?value . # The item has a predicate and a value - i.e. let's look at all triples for this item.
?property wikibase:directClaim ?predicate . # the ?predicate is a directClaim (i.e. a wdt: type predicate)
# it is a predicate of the ?property
# and the clause is specifying that we're only interested in seeing wdt: predicates for the item
} group by ?property } # so we get the result of the named query, above, here, which will be a list of property wd: values
# and counts for each property; and now we can get the label for each property.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
} order by desc(?count)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?count"):::projected
v2("?item")
v3("?predicate")
v5("?property"):::projected
v4("?value")
c2(["wd:Q23397"]):::iri
c7(["bd:serviceParam"]):::iri
c9(["en"]):::literal
c4(["wd:Q145"]):::iri
v2 --"wdt:P31"--> c2
v2 --"wdt:P17"--> c4
v2 -->v3--> v4
v5 --"wikibase:directClaim"--> v3
bind1[/"count(?item)"/]
v2 --o bind1
bind1 --as--o v6
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end