PREFIX era: PREFIX xsd: SELECT DISTINCT ?country (COUNT(DISTINCT ?track) AS ?countTracks) WHERE { GRAPH { ?sectionOfLine a era:SectionOfLine . ?sectionOfLine era:inCountry ?country . ?sectionOfLine era:track ?track . ?track a era:Track . ?track era:hasTSITrainDetection "false"^^xsd:boolean } } ORDER BY ?country