PAGUE 6 MESES
LEVE 12 MESES
GARANTIR DESCONTO

Fórum obter a media em uma procedure no IBexpert, quem pode ajudar? #413848

08/03/2012

0

Pessoal,

Estou tentando fazer a média em uma procedure no IBexpert, mas esta mim retornado zero(0), alguem pode ajudar? veja como está o codigo:

begin
for
select n.disciplina_notas,
d.nome_disciplina,
count(*) as qtde_notas,

(select n1.nota
from notas n1
where n1.disciplina_notas = n.disciplina_notas
and n1.matricula_aluno_notas = n.matricula_aluno_notas
and n1.codigo_turma_notas = n.codigo_turma_notas
and n1.bimestre = 1 BIMESTRE) nota_1,

(select n2.nota
from notas n2
where n2.disciplina_notas = n.disciplina_notas
and n2.matricula_aluno_notas = n.matricula_aluno_notas
and n2.codigo_turma_notas = n.codigo_turma_notas
and n2.bimestre = 2 BIMESTRE) nota_2,

(select n3.nota
from notas n3
where n3.disciplina_notas = n.disciplina_notas
and n3.matricula_aluno_notas = n.matricula_aluno_notas
and n3.codigo_turma_notas = n.codigo_turma_notas
and n3.bimestre = 3 BIMESTRE) nota_3,

(select n4.nota
from notas n4
where n4.disciplina_notas = n.disciplina_notas
and n4.matricula_aluno_notas = n.matricula_aluno_notas
and n4.codigo_turma_notas = n.codigo_turma_notas
and n4.bimestre = 4 BIMESTRE) nota_4,


(select n5.nota
from notas n5
where n5.disciplina_notas = n.disciplina_notas
and n5.matricula_aluno_notas = n.matricula_aluno_notas
and n5.codigo_turma_notas = n.codigo_turma_notas
and n5.bimestre = 1 RECUPERACAO) nota_5,


(select n6.nota
from notas n6
where n6.disciplina_notas = n.disciplina_notas
and n6.matricula_aluno_notas = n.matricula_aluno_notas
and n6.codigo_turma_notas = n.codigo_turma_notas
and n6.bimestre = 2 RECUPERACAO) nota_6,


(select n7.nota
from notas n7
where n7.disciplina_notas = n.disciplina_notas
and n7.matricula_aluno_notas = n.matricula_aluno_notas
and n7.codigo_turma_notas = n.codigo_turma_notas
and n7.bimestre = 3 RECUPERACAO) nota_7


from notas n left join disciplina d on n.disciplina_notas = d.codigo
where n.matricula_aluno_notas =:MATRICULA_ALUNO
and n.codigo_turma_notas =:CODIGO_TURMA

group by n.disciplina_notas,
d.nome_disciplina,
n.matricula_aluno_notas,
n.matricula_aluno_notas,
n.codigo_turma_notas

into :CODIGO,
:NOME_DISCIPLINA,
:QTDE_NOTAS_ANO,
:nota1,
:nota2,
:nota3,
:nota4,
:nota5,
:nota6,
:nota7

do
begin
begin

if ((NOTA1) < 60 and (NOTA5) > (NOTA1)) then
NOTA1 = NOTA5;
else
NOTA1 = NOTA1;
end

begin
if ((NOTA2) < 60 and (NOTA5) > (nota2)) then
NOTA2 = NOTA5;
else
NOTA2 = NOTA2;
end

begin
if ((NOTA3) < 60 and (NOTA6) > (nota3)) then
NOTA3 = NOTA6;
else
NOTA3 = NOTA3;
end

begin
if ((NOTA4) < 60 and (NOTA6) > (NOTA4)) then
NOTA4 = NOTA6;
else
NOTA4 = NOTA4;

media_bimestral = (nota1 + nota2 + nota3 + nota4);

end

end
end
Osmar

Osmar

Responder

Posts

08/03/2012

Osmar

Pessoal,

Estou tentando fazer a média em uma procedure no IBexpert, mas esta mim retornado zero(0), alguem pode ajudar? veja como está o codigo:

begin
for
select n.disciplina_notas,
d.nome_disciplina,
count(*) as qtde_notas,

(select n1.nota
from notas n1
where n1.disciplina_notas = n.disciplina_notas
and n1.matricula_aluno_notas = n.matricula_aluno_notas
and n1.codigo_turma_notas = n.codigo_turma_notas
and n1.bimestre = 1 BIMESTRE) nota_1,

(select n2.nota
from notas n2
where n2.disciplina_notas = n.disciplina_notas
and n2.matricula_aluno_notas = n.matricula_aluno_notas
and n2.codigo_turma_notas = n.codigo_turma_notas
and n2.bimestre = 2 BIMESTRE) nota_2,

(select n3.nota
from notas n3
where n3.disciplina_notas = n.disciplina_notas
and n3.matricula_aluno_notas = n.matricula_aluno_notas
and n3.codigo_turma_notas = n.codigo_turma_notas
and n3.bimestre = 3 BIMESTRE) nota_3,

(select n4.nota
from notas n4
where n4.disciplina_notas = n.disciplina_notas
and n4.matricula_aluno_notas = n.matricula_aluno_notas
and n4.codigo_turma_notas = n.codigo_turma_notas
and n4.bimestre = 4 BIMESTRE) nota_4,


(select n5.nota
from notas n5
where n5.disciplina_notas = n.disciplina_notas
and n5.matricula_aluno_notas = n.matricula_aluno_notas
and n5.codigo_turma_notas = n.codigo_turma_notas
and n5.bimestre = 1 RECUPERACAO) nota_5,


(select n6.nota
from notas n6
where n6.disciplina_notas = n.disciplina_notas
and n6.matricula_aluno_notas = n.matricula_aluno_notas
and n6.codigo_turma_notas = n.codigo_turma_notas
and n6.bimestre = 2 RECUPERACAO) nota_6,


(select n7.nota
from notas n7
where n7.disciplina_notas = n.disciplina_notas
and n7.matricula_aluno_notas = n.matricula_aluno_notas
and n7.codigo_turma_notas = n.codigo_turma_notas
and n7.bimestre = 3 RECUPERACAO) nota_7


from notas n left join disciplina d on n.disciplina_notas = d.codigo
where n.matricula_aluno_notas =:MATRICULA_ALUNO
and n.codigo_turma_notas =:CODIGO_TURMA

group by n.disciplina_notas,
d.nome_disciplina,
n.matricula_aluno_notas,
n.matricula_aluno_notas,
n.codigo_turma_notas

into :CODIGO,
:NOME_DISCIPLINA,
:QTDE_NOTAS_ANO,
:nota1,
:nota2,
:nota3,
:nota4,
:nota5,
:nota6,
:nota7

do
begin
begin

if ((NOTA1) < 60 and (NOTA5) > (NOTA1)) then
NOTA1 = NOTA5;
else
NOTA1 = NOTA1;
end

begin
if ((NOTA2) < 60 and (NOTA5) > (nota2)) then
NOTA2 = NOTA5;
else
NOTA2 = NOTA2;
end

begin
if ((NOTA3) < 60 and (NOTA6) > (nota3)) then
NOTA3 = NOTA6;
else
NOTA3 = NOTA3;
end

begin
if ((NOTA4) < 60 and (NOTA6) > (NOTA4)) then
NOTA4 = NOTA6;
else
NOTA4 = NOTA4;

media_bimestral = (nota1 + nota2 + nota3 + nota4)/4; //desculpem esqueci de colocar o divisor

end

end
end
Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar