Docentes em turmas extintas
De MSTECH wiki
1 /*
2 - Docentes não regência (exibir ano letivo, turma, disciplina) - Só turmas/atribuições ativas
3 */
4
5 USE TESTE_SGP_GestaoPedagogica
6 GO
7
8 SELECT
9 Uad.uad_nome AS DRE
10 , Esc.esc_nome AS Escola
11 , Pes.pes_nome as Docente
12 , Coc.coc_matricula AS [login]
13 , Tdc.tdc_nome AS TipoDocente
14 , Cal.cal_ano AS AnoLetivo
15 , Tur.tur_codigo AS Turma
16 , CASE Tur.tur_tipo WHEN 1 THEN 'Normal' WHEN 2 THEN 'Recuperação paralela' WHEN 3 THEN 'Educação Física' WHEN 4 THEN 'Educação Física' ELSE '' END AS TipoTurma
17 , Tud.tud_nome AS Disciplina
18 , Tur.tur_id
19 , Tud.tud_id
20 , tud_tipo
21 , Tur.esc_id
22 , (SELECT COUNT(alu_id) FROM MTR_MatriculaTurma WITH(NOLOCK) WHERE tur_id = Tur.tur_id AND mtu_situacao <> 3) AS QtAlunos
23 FROM TUR_TurmaDocente Tdt WITH(NOLOCK)
24 INNER JOIN TUR_TurmaDisciplina Tud WITH(NOLOCK)
25 ON Tud.tud_id = Tdt.tud_id
26 inner join TUR_TurmaRelTurmaDisciplina RelTud WITH(NOLOCK)
27 ON Reltud.tud_id = Tud.tud_id
28 INNER JOIN ACA_TipoDocente Tdc WITH(NOLOCK)
29 ON Tdc.tdc_posicao = Tdt.tdt_posicao
30 INNER JOIN TUR_Turma Tur WITH(NOLOCK)
31 ON Tur.tur_id = RelTud.tur_id
32 INNER JOIN ACA_CalendarioAnual Cal WITH(NOLOCK)
33 ON Cal.cal_id = Tur.cal_id
34 INNER JOIN ACA_Docente Doc WITH(NOLOCK)
35 ON Doc.doc_id = Tdt.doc_id
36 INNER JOIN RHU_Colaborador Col WITH(NOLOCK)
37 ON Col.col_id = Doc.col_id
38 AND Col.col_situacao <> 3
39 INNER JOIN RHU_ColaboradorCargo Coc WITH(NOLOCK)
40 ON Coc.col_id = Col.col_id
41 AND Coc.crg_id = Tdt.crg_id
42 AND Coc.coc_id = Tdt.coc_id
43 AND Coc.coc_situacao <> 3
44 INNER JOIN Synonym_PES_Pessoa Pes WITH(NOLOCK)
45 ON Pes.pes_id = Col.pes_id
46 INNER JOIN Synonym_SYS_Usuario Usu WITH(NOLOCK)
47 ON Usu.pes_id = Pes.pes_id
48 AND Usu.usu_situacao <> 3
49 INNER JOIN ESC_Escola Esc WITH(NOLOCK)
50 ON Esc.esc_id = Tur.esc_id
51 INNER JOIN Synonym_SYS_UnidadeAdministrativa Uad WITH(NOLOCK)
52 ON Uad.ent_id = Esc.ent_id
53 AND Uad.uad_id = Esc.uad_idSuperiorGestao
54 WHERE
55 Tdt.tdt_situacao IN (1,4)
56 AND Tur.tur_situacao = 7 -- Extinta
57 AND Tud.tud_situacao <> 3
58
59
60 order by
61 Uad.uad_nome
62 , Esc.esc_nome
63 , Pes.pes_nome
64 , Coc.coc_matricula
65 , Tur.tur_codigo
66 , Tud.tud_nome
67 , Tdc.tdc_nome