A set of SPARQL examples
Most used external IDs for items with an InChIKey.
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX hint: <http://www.bigdata.com/queryHints#>
#title:Most used external IDs for items with an InChIKey (P235)
SELECT ?p ?propLabel (COUNT(?item) AS ?count) WHERE {
SERVICE bd:sample {
?item p:P235 [].
bd:serviceParam bd:sample.limit 10000 .
}
hint:Prior hint:runFirst true.
?item ?p [].
hint:Prior hint:rangeSafe true.
?prop wikibase:directClaim ?p.
hint:Prior hint:rangeSafe true.
?prop wikibase:propertyType wikibase:ExternalId.
hint:Prior hint:rangeSafe true.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
GROUP BY ?p ?propLabel
ORDER BY DESC (?count)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?count")
v2("?item"):::projected
v3("?p"):::projected
v4("?prop")
a1((" "))
a2((" "))
c6([http://www.bigdata.com/queryHints#Prior]):::iri
c12(["wikibase:ExternalId"]):::iri
c15(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
c3([http://www.bigdata.com/rdf#serviceParam]):::iri
c5(["10000^^xsd:integer"]):::literal
c8(["true^^xsd:boolean"]):::literal
subgraph s1["http://www.bigdata.com/rdf#sample"]
style s1 stroke-width:4px;
v2 --"p:P235"--> a1
c3 --http://www.bigdata.com/rdf#sample.limit--> c5
end
c6 --http://www.bigdata.com/queryHints#runFirst--> c8
v2 -->v3--> a2
c6 --http://www.bigdata.com/queryHints#rangeSafe--> c8
v4 --"wikibase:directClaim"--> v3
c6 --http://www.bigdata.com/queryHints#rangeSafe--> c8
v4 --"wikibase:propertyType"--> c12
c6 --http://www.bigdata.com/queryHints#rangeSafe--> c8
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c3 --"wikibase:language"--> c15
end
bind1[/"count(?item)"/]
v2 --o bind1
bind1 --as--o v5