[firebase-br] erro em select agrupavel
Paulo S X Soares
paulosoares.br em gmail.com
Sex Fev 8 19:30:58 -03 2008
Uma dica: crie uma tabela de meses e faça
Select
M.Mes,
sum(P.valordesconto) As Totaldesconto,
sum(P.valorprevisto) As Totalbruto,
count(P.*) as qtde
from PEDIDO P
left outer join Meses M on M.Id=coalesce(extract( month from
P.DataAbertura),0)
where P.dataabertura between '01/01/2008' and '12/31/2008'
group by 1
2008/2/8, Cmte Wilson <wilson.butigeli em itelefonica.com.br>:
>
> Estou tentando fazer um select agrupando por mes mas dá erro no
> month(p.dataabertura) alegando que a expressao month nao existe.
> O erro acontece no IBExpert e no aplicativo.
>
> Linguagem VB 6 com firebird 1.5.5
>
> Abaixo o select utilizado montado em cima do exemplo retirado do livro
> firebird essencial página 20:
>
> Select
> case
> when (month(P.dataabertura) in ('01')) then 'JANEIRO'
> when (month(P.dataabertura) in ('02')) then 'FEVEREIRO'
> when (month(P.dataabertura) in ('03')) then 'MARÇO'
> when (month(P.dataabertura) in ('04')) then 'ABRIL'
> when (month(P.dataabertura) in ('05')) then 'MAIO'
> when (month(P.dataabertura) in ('06')) then 'JUNHO'
> when (month(P.dataabertura) in ('07')) then 'JULHO'
> when (month(P.dataabertura) in ('08')) then 'AGOSTO'
> when (month(P.dataabertura) in ('09')) then 'SETEMBRO'
> when (month(P.dataabertura) in ('10')) then 'OUTUBRO'
> when (month(P.dataabertura) in ('11')) then 'NOVEMBRO'
> when (month(P.dataabertura) in ('12')) then 'DEZEMBRO'
> else 'DESCONHECIDO'
> end as mes,
> sum(P.valordesconto) As Totaldesconto,
> sum(P.valorprevisto) As Totalbruto,
> count(P.*) as qtde
> from PEDIDO P
> where P.dataabertura between '01/01/2008' and '12/31/2008'
> group by 1
>
> Obrigado
> Wilson
>
>
> ______________________________________________
> FireBase-BR (www.firebase.com.br) - Hospedado em www.locador.com.br
> Para saber como gerenciar/excluir seu cadastro na lista, use:
> http://www.firebase.com.br/fb/artigo.php?id=1107
> Para consultar mensagens antigas: http://firebase.com.br/pesquisa
>
--
___________________________________
*** Paulo Sergio Xavier Soares ***
Skype: Allumo, E-mail: paulosoares.br em gmail.com, MSN: paulosxs em yahoo.com.br
Consultor em Informatica
Matematica - UEM
Obs: Se o seu leitor de e-mail não estiver configurado para emitir resposta
automática do recebimento, favor responder essa mensagem para o confirmar.
Mais detalhes sobre a lista de discussão lista