How many {has active ingredient} are to/by {fentanyl} ?
Fentanyl has what active ingredient?
What's the active ingredient in fentanyl?
SELECT ( COUNT ( ?h ) AS ?g ) { ?h property:has_active_ingredient resource:fentanyl }
SELECT (COUNT(?sub) AS ?subs ) {
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> ?sub .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.wikidata.org/entity/P3781> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> http://wikidata.dbpedia.org/resource/Q407541 .
} 

SELECT (COUNT(?sub) AS ?value ) { ?sub wdt:P3781 wd:Q407541 }
9