[firebase-br] UNION

gutopj02 em gmail.com gutopj02 em gmail.com
Dom Mar 26 13:24:53 -03 2017


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



Mais detalhes sobre a lista de discussão lista