Re: UNION?

Поиск
Список
Период
Сортировка
От Manfred Koizar
Тема Re: UNION?
Дата
Msg-id i95o2v8qnm8iagfihnm5st6fdhtft1fnf8@4ax.com
обсуждение исходный текст
Ответ на UNION?  (Forest Felling <res08i7v@verizon.net>)
Список pgsql-novice
On Mon, 20 Jan 2003 08:52:09 -0500, Forest Felling
<res08i7v@verizon.net> wrote:
>mydb=# select count(city) as qty, code as code
>    from test_year
>    where length(code) = 1
>    group by code
>    order by code
>    union all
>    select count(city) as qty, 'All' as code
>    from test_year
>    where length(code) = 1
>ERROR:  parser: parse error at or near "all"
>Drop ALL, and get
>ERROR:  parser: parse error at or near "select"

Try
    SELECT * FROM (
        SELECT ...
          FROM test_year ...
         GROUP BY ...
         ORDER BY ... ) AS t1
    UNION ALL
    SELECT count(...), 'All' ...

or
    SELECT 1, count(city) as qty, code as code
      FROM ...
     GROUP BY
    UNION ALL
    SELECT 2, count(city) as qty, 'All' as code
      FROM ...
     ORDER BY 1, 3;

Servus
 Manfred

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

Предыдущее
От: Conxita Marín
Дата:
Сообщение: Re: quoted_literal with numeric variable
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Database Performance problem