How many {studies} are to/by {history} ?
Which is the number of them studying history?
How many of them study history?
SELECT ( COUNT ( ?c ) AS ?e ) { ?c property:studies resource:history }
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/P2578> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> http://wikidata.dbpedia.org/resource/Q309 .
} 

SELECT (COUNT(?sub) AS ?value ) { ?sub wdt:P2578 wd:Q309 }
7