I am writing a query in SPARQL for a knowledge graph. I have a column having Country and names of countries repeating. For example: Japan, India, US, India, India, US, US, Romania etc. and so on.
I need to write a SPARQL query that gives me the count of each country in that column. Example: Japan 1, India 3, US 3 etc. and so on.
SELECT ?countryName COUNT(?CountryName)
WHERE
{
...
}
GROUP BY ?countryName
HAVING (?countryName = "Germany")
Try something like this:
Keep in mind that you will need to replace OBJECT with the entity type, and I have assumed you are using the
rdfs:label
predicate for the labels.