[firebase-br] Comando AVG retorna errado
Zottis
bzottis em ig.com.br
Qua Set 26 11:40:26 -03 2012
Pessoal, tenho um SQL que é para receber a média das notas recebidas do
imóvel, mas faço de dois jeitois e retorna 5 ao invés de 5,5
O que estou fazendo errado?
Desde já agardeço
O SQL é este:
select i.COD_IMOVEL, ......
(select Count(ch.cod_chave) from chaves Ch where ch.cod_imovel =
i.cod_imovel)Visitas, /* Aqui Retorna 2*/
(select sum(ch.nota_recebida) from chaves Ch where ch.cod_imovel =
i.cod_imovel)SomaNotas,/*Aqui retorna 11*/
cast(((select sum(ch.nota_recebida) from chaves Ch where
ch.cod_imovel = i.cod_imovel)
/ (select Count(ch.cod_chave) from chaves Ch where ch.cod_imovel
= i.cod_imovel))as taxas) notaMedia,/*Aqui esta retornando 5,00*/
(select AVG(ch2.nota_recebida) from chaves Ch2 where ch2.cod_imovel =
i.cod_imovel)notaMedia2 /*Aqui esta retornando 5*/
from IMOVEL i
where i.COD_IMOVEL =:VarCod_Imovel
Mais detalhes sobre a lista de discussão lista