SELECT ?class (COUNT(?s) AS ?n) WHERE { ?s a ?class . } GROUP BY ?class ORDER BY DESC(?n) LIMIT 20
rete playground · documentation · github.com/caviri/rete