fs_person_table = Table('PERSON', fsmeta, autoload=True, schema='FS') fs_student_table = Table('STUDENT', fsmeta, autoload=True, schema='FS') fs_studprogstudent_table = Table('STUDIEPROGRAMSTUDENT', fsmeta, autoload=True, schema='FS') fs_kullklassestudent_table = Table('KULLKLASSESTUDENT', fsmeta, autoload=True, schema='FS') persons_select = select( [ fs_student_table.c.studentnr_tildelt, fs_person_table.c.fodselsdato, fs_person_table.c.personnr, fs_person_table.c.fornavn, fs_person_table.c.etternavn, fs_studprogstudent_table.c.studentstatkode, fs_studprogstudent_table.c.studierettstatkode, ], and_( fs_student_table.c.fodselsdato == fs_studprogstudent_table.c.fodselsdato, fs_student_table.c.personnr == fs_studprogstudent_table.c.personnr, fs_person_table.c.fodselsdato == fs_studprogstudent_table.c.fodselsdato, fs_person_table.c.personnr == fs_studprogstudent_table.c.personnr, fs_kullklassestudent_table.c.fodselsdato == fs_studprogstudent_table.c.fodselsdato, fs_kullklassestudent_table.c.personnr == fs_studprogstudent_table.c.personnr, fs_kullklassestudent_table.c.studieprogramkode == fs_studprogstudent_table.c.studieprogramkode, fs_kullklassestudent_table.c.status_aktiv == 'J', or_( fs_studprogstudent_table.c.studentstatkode == 'AKTIV', fs_studprogstudent_table.c.studentstatkode == 'PERMISJON', ) ) ).order_by( fs_student_table.c.studentnr_tildelt, fs_kullklassestudent_table.c.arstall, fs_kullklassestudent_table.c.terminkode, fs_kullklassestudent_table.c.studieprogramkode, fs_kullklassestudent_table.c.klassekode, fs_studprogstudent_table.c.dato_studierett_tildelt, fs_studprogstudent_table.c.studentstatkode, ).limit(100)