Sum of city using group by country in sparql query
<p>I want to calculate the total number of cities per country using a SPARQL query in Protege tool.  The relation between city and country is that city <code>isLocatedIn</code> country. I tried this query that are given below but it fails.  So kindly help me.</p>

<pre><code>PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
PREFIX owl: &lt;http://www.w3.org/2002/07/owl#&gt;
PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
 PREFIX ge:&lt;http://www.semanticweb.org/waqas/ontologies/2016/4/untitled-ontology-15#&gt;
SELECT  ( ?country SUM(?city) AS  ?TotalCity )
    WHERE {  ?city ge:isLocatedIn ?country . ?city rdf:type ?city} 
    GROUP BY(?country)
</code></pre>