1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| create or replace view v_notes as
select distinct n.id as note_id,
m.id_matiere as mat_id,
case
when n.dat_note is null or trim(n.dat_note ="") then NULL
when month(n.dat_note) < 9 then year(n.dat_note)-1
when month(n.dat_note) >=9 then year(n.dat_note)
else 0 /*ici 0 sera une anomalie signifiant que tu dois corriger ta date*/
end as an_scol,
n.trimestre as note_trimestre,
n.dat_note as note_date,
e.id_eleve as eleve_id,
e.id_classe as eleve_classe,
e.nom as eleve_nom,
n.designation as note_designation,
n.note as note_valeur,
(n.note * m.coef) as note_coeff,
m.id_prof as mat_prof,
m.matiere as mat_libelle,
m.coef as mat_coeff
from alp_notes n
left join alp_matieres m on n.id_mat=m.id_matiere
left join alp_eleves e on n.id_elv=e.id_eleve |