How to use an alias name in the current select

Поиск
Список
Период
Сортировка
От Guy Deleeuw
Тема How to use an alias name in the current select
Дата
Msg-id 4BAA40E2.3000805@eurofer.be
обсуждение исходный текст
Ответы Re: How to use an alias name in the current select  (Dimitri Fontaine <dfontaine@hi-media.com>)
Список pgsql-admin
Hello

I have :
    SELECT
          t_orders_articles.k_id            AS k_id
         ,t_orders_articles.quantity        AS order_qty
         ,(SELECT sum(quantity) FROM t_deliveries_articles WHERE
article_id = t_orders_articles.k_id) AS delivery_qty
         , (t_orders_articles.quantity - delivery_qty)       AS qty
       FROM t_orders_articles
        ......;

But it's not working I receive the error :
ERROR : The column delivery_qty does not exist.

How can I make that without having 2 select call ?

Regards
Guy


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

Предыдущее
От: blast
Дата:
Сообщение: Re: Backup&Restore Postgres DB
Следующее
От: Ray Stell
Дата:
Сообщение: 8.2.15 pitr/00000001.history