Calcule d'une moyenne Pondérée

-
Bonjour,
Je veux transformer cette moyenne en moyenne pondérée,

(cast(cast(sum(NOTE_QUESTION_1) as numeric(10,2))/cast(sum(case when NOTE_QUESTION_1 is not null then 1 else 0 end) as numeric(10,2)) as decimal(10,5))
 +cast(cast(sum(NOTE_QUESTION_2) as numeric(10,2))/cast(sum(case when NOTE_QUESTION_2 is not null then 1 else 0 end) as numeric(10,2)) as decimal(10,5))
 +cast(cast(sum(NOTE_QUESTION_3) as numeric(10,2))/cast(sum(case when NOTE_QUESTION_3 is not null then 1 else 0 end) as numeric(10,2)) as decimal(10,5))
 )/3 as valeur


j'ai essayé le code ci dessous mais ça ne marche pas et j'ai des valeurs incohérentes.

(cast(cast(sum(NOTE_QUESTION_1) as numeric(10,2))*cast(sum(case when NOTE_QUESTION_1 is not null then 1 else 0 end) as numeric(10,2)) as decimal(10,5))
 +cast(cast(sum(NOTE_QUESTION_2) as numeric(10,2))*cast(sum(case when NOTE_QUESTION_2 is not null then 1 else 0 end) as numeric(10,2)) as decimal(10,5))
 +cast(cast(sum(NOTE_QUESTION_3) as numeric(10,2))*cast(sum(case when NOTE_QUESTION_3 is not null then 1 else 0 end) as numeric(10,2)) as decimal(10,5))
 )/(sum(case when NOTE_QUESTION_1 is not null then 1 else 0 end)+sum(case when NOTE_QUESTION_2 is not null then 1 else 0 end)+sum(case when NOTE_QUESTION_3 is not null then 1 else 0 end)) as valeur


Merci d'avance pour votre aide.
A voir également: