Index: /main/waeup.kofa/trunk/CHANGES.txt
===================================================================
--- /main/waeup.kofa/trunk/CHANGES.txt	(revision 13235)
+++ /main/waeup.kofa/trunk/CHANGES.txt	(revision 13236)
@@ -4,4 +4,6 @@
 1.3.2.dev0 (unreleased)
 =======================
+
+* Fix department breakdown of student statistics.
 
 * Enable purging of applicants containers.
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_statistics.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_statistics.py	(revision 13235)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_statistics.py	(revision 13236)
@@ -40,5 +40,5 @@
     Returns a table ordered by code (faculty or department, one per row) and
     registration state (cols). The result is a 3-tuple representing
-    ((<CODES>), (<STATES>), (<NUM_OF_STUDENTS>)). The
+    ((<PATHS>), (<STATES>), (<NUM_OF_STUDENTS>)). The
     (<NUM_OF_STUDENTS>) is an n-tuple with each entry containing the
     number of students found in that faculty/department and with the respective
@@ -58,17 +58,12 @@
     states = states + (u'Total',)
     if breakdown == 'faccode':
-        codes = tuple(sorted([x for x in site['faculties'].keys()],
+        paths = tuple(sorted([x for x in site['faculties'].keys()],
                                  key=lambda x: x.lower()))
-        paths = codes
     elif breakdown == 'depcode':
         faculties = site['faculties']
-        depcodes = []
         deppaths = []
         for fac in faculties.values():
             for dep in fac.values():
-                depcodes.append(dep.code)
                 deppaths.append('%s/%s' % (fac.code, dep.code))
-        codes = tuple(sorted([x for x in depcodes],
-                                 key=lambda x: x.lower()))
         paths = tuple(sorted([x for x in deppaths],
                                  key=lambda x: x.lower()))
@@ -79,5 +74,5 @@
     cat = queryUtility(ICatalog, name="students_catalog")
     result = cat.searchResults(current_session=(session, session))
-    table = [[0 for x in xrange(len(states))] for y in xrange(len(codes)+1)]
+    table = [[0 for x in xrange(len(states))] for y in xrange(len(paths)+1)]
     mode_groups = getUtility(IKofaUtils).MODE_GROUPS
     for stud in result:
@@ -86,8 +81,12 @@
         if level != 0 and stud.current_level != level:
             continue
-        if getattr(stud, breakdown) not in codes:
-            # studs can have a faccode ``None``
+        if getattr(stud, breakdown) is None:
             continue
-        row = codes.index(getattr(stud, breakdown))
+        if breakdown == 'faccode':
+            row_name = getattr(stud, 'faccode')
+        elif breakdown == 'depcode':
+            row_name = '%s/%s' % (
+                getattr(stud, 'faccode'), getattr(stud, 'depcode'))
+        row = paths.index(row_name)
         col = states.index(stud.state)
         table[row][col] += 1
