[firebase-br] UNION
Giovani Saccomori
gigioh4 em gmail.com
Dom Mar 26 14:14:39 -03 2017
Order by coloca no final...
Em 26 de mar de 2017 13:31, "José Ivair Rodrigues" <joseivair1971 em gmail.com>
escreveu:
> Boa tarde !
>
> Tente tirar o order by do primeiro select.
>
> Att. Ivair
>
> Em 26 de março de 2017 13:24, <gutopj02 em gmail.com> escreveu:
>
> >
> > Olá a todos,
> >
> > Alguém sabe me dizer o porque esse UNION não funciona?
> > Mesma tabela, mesmos campos, só muda o where.
> > obrigado
> >
> > SELECT
> > case cidade
> > when 1 then 'Jaú'
> > when 2 then 'Bariri'
> > when 3 then 'B. Bonita'
> > when 4 then 'Bocaina'
> > when 5 then 'Boraceia'
> > when 6 then 'Brotas'
> > when 7 then 'D. Corregos'
> > when 8 then 'Igaraçu'
> > when 9 then 'Itaju'
> > when 10 then 'Itapui'
> > when 11 then 'Mineiros'
> > when 12 then 'Torrinha'
> > when 13 then 'Outras'
> > else
> > 'Erro'
> > end as NCidade,
> > sum( qtdade ) as TTCid
> > from agenda
> > WHERE situacao='A'
> > group by cidade
> > order by cidade
> >
> > UNION
> >
> > SELECT
> > case cidade
> > when 1 then 'Jaú'
> > when 2 then 'Bariri'
> > when 3 then 'B. Bonita'
> > when 4 then 'Bocaina'
> > when 5 then 'Boraceia'
> > when 6 then 'Brotas'
> > when 7 then 'D. Corregos'
> > when 8 then 'Igaraçu'
> > when 9 then 'Itaju'
> > when 10 then 'Itapui'
> > when 11 then 'Mineiros'
> > when 12 then 'Torrinha'
> > when 13 then 'Outras'
> > else
> > 'Erro'
> > end as NCidade,
> > sum( qtdade ) as TTCid
> > from agenda
> > WHERE situacao='C'
> > group by cidade
> > order by cidade
> > ______________________________________________
> > 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://www.firebase.com.br/
> > pesquisa_lista.html
> >
> ______________________________________________
> 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://www.firebase.com.br/
> pesquisa_lista.html
>
Mais detalhes sobre a lista de discussão lista