diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js
index 1b00739529d7b6ca9756125be487ec9a5dee6d1a..26d1cd6fcea5ed231bf16664dc15026499736fac 100644
--- a/src/libs/routes/enrollment.js
+++ b/src/libs/routes/enrollment.js
@@ -117,7 +117,7 @@ enrollmentApp.use('/', (req, res, next) => {
             .field('SUM(total)', 'total')
             .field('ano_censo', 'year');
 
-        filter(q);
+        filter(req, q);
 
         if (typeof req.id !== 'undefined') {
             q.where('pk_regiao_id=?', req.id);
@@ -165,6 +165,25 @@ enrollmentApp.use('/', (req, res, next) => {
     next();
 });
 
+enrollmentApp.use('/', (req, res, next) => {
+    const params = req.query;
+    if (typeof params.aggregate !== 'undefined' && params.aggregate === 'school') {
+        log.debug('Using enrollments query for schools');
+        const q = squel.select().from('mat_escolas')
+            .field('name')
+            .field('SUM(total)', 'total')
+            .field('ano_censo', 'year');
+
+        filter(req, q);
+
+        if (typeof req.id !== 'undefined') {
+            q.where('pk_escola_id=?', req.id);
+        }
+        req.sql = q.group('name').group('ano_censo').order('ano_censo').toParam();
+    }
+    next();
+});
+
 enrollmentApp.use('/', (req, res, next) => {
     const params = req.query;
     if (typeof params.aggregate === 'undefined') {