How many {studied by} are to/by {astronomy} ?
How many students studied astronomy?
How many students studied the subject {astronomy} ?
SELECT ( COUNT ( ?d ) AS ?g ) { ?d property:studied_by resource:astronomy }
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/P2579> .
?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> http://wikidata.dbpedia.org/resource/Q333 .
} 

SELECT (COUNT(?sub) AS ?value ) { ?sub wdt:P2579 wd:Q333 }
15