[firebase-br] UNION

Marcelo marcelo em magnosystem.com.br
Seg Mar 27 11:58:25 -03 2017


group by 1

order by 1

Tenta assim.

Em 26/03/2017 14:14, Giovani Saccomori escreveu:
> 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
>>
> ______________________________________________
> 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