UNION not working... why?

Поиск
Список
Период
Сортировка
От Stefan Schwarzer
Тема UNION not working... why?
Дата
Msg-id 1F4B1232-04B0-49A2-B291-811CC7D25E39@grid.unep.ch
обсуждение исходный текст
Ответы Re: UNION not working... why?  (Richard Huxton <dev@archonet.com>)
Re: UNION not working... why?  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Список pgsql-general
Hi there,

I have two rather simple queries, which I would to UNION, but somehow I always get an error message for the UNION ("ERROR:  syntax error at or near "UNION"")

Each query selects the country name ("Switzerland" in this case), the most recent year in the table and its value.

What is wrong with it? Thanks for any hints!


SELECT 
c.name,
d.year_start, 
d.value
FROM 
emissions_so2_total_rivm AS d
LEFT JOIN 
countries AS c ON c.id = d.id_country
WHERE
((c.iso_2_code = 'CH') OR (c.iso_3_code = 'CH')) 
ORDER BY 
d.year_start DESC
LIMIT 1

UNION ALL

SELECT 
c.name,
d.year_start, 
d.value
FROM 
pop_density AS d
LEFT JOIN 
countries AS c ON c.id = d.id_country
WHERE
((c.iso_2_code = 'CH') OR (c.iso_3_code = 'CH')) 
ORDER BY 
d.year_start DESC
LIMIT 1



 ____________________________________________________________________

  

  Stefan Schwarzer
  
  Lean Back and Relax - Enjoy some Nature Photography

  Appetite for Global Data? UNEP GEO Data Portal:  
  ____________________________________________________________________






В списке pgsql-general по дате отправления:

Предыдущее
От: Tatsuo Ishii
Дата:
Сообщение: Re: timestamp with time zone
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: UNION not working... why?