Fórum Erro ao ordenar por ( Somatoria feita em SQL ) !!! #236588
08/06/2004
0
Sql :=´ Select Peao.nome,peao.cidade,Notas.total,Notas.data,(Touro.nome)As NTouro,(C.Nome)As NCia,SUM(Notas.Total)As Geral From Peao,Notas,Sorteio,Touro,[Cia de Rodeio]AS C ´+
´ Where ((Notas.idSorteio=sorteio.codigo and Notas.valida=:V) and (Sorteio.Peao=Peao.id and Sorteio.Touro=Touro.id_Touro))´+
´ and ((Touro.id_cia=C.id_cia) and( Notas.data >=:Inicial and Notas.data<=:Final)) ´ +
´ Group By Peao.nome,peao.cidade,Notas.total,Notas.data,(Touro.nome)As NTouro,(C.Nome)As NCia´+
´ Order By Notas.Geral´;
Pessoal tenho ai uma consulta e quero ordenar pelo somatorio que fiz
# SUM(Notas.Total)As Geral e esta dando erro..
Grato Michel
´ Where ((Notas.idSorteio=sorteio.codigo and Notas.valida=:V) and (Sorteio.Peao=Peao.id and Sorteio.Touro=Touro.id_Touro))´+
´ and ((Touro.id_cia=C.id_cia) and( Notas.data >=:Inicial and Notas.data<=:Final)) ´ +
´ Group By Peao.nome,peao.cidade,Notas.total,Notas.data,(Touro.nome)As NTouro,(C.Nome)As NCia´+
´ Order By Notas.Geral´;
Pessoal tenho ai uma consulta e quero ordenar pelo somatorio que fiz
# SUM(Notas.Total)As Geral e esta dando erro..
Grato Michel
Michel
Curtir tópico
+ 0
Responder
Posts
08/06/2004
Ruysalles
Tente assim:
Select P.nome, P.cidade, N.total, N.data, T.nome As NTouro, C.Nome As NCia, SUM(N.Total) As Geral From Peao P,Notas N,Sorteio S,Touro S,[Cia de Rodeio]AS C ´+ Where N.idSorteio = S.codigo and N.valida=:V and S.Peao=P.id and S.Touro=T.id_Touro and T.id_cia=C.id_cia and N.data >=:Inicial and Notas.data<=:Final Group By P.nome, P.cidade, N.total, N.data, NTouro, NCia Order By SUM(N.Total)
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)