Re: Condition in a calculated field

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: Condition in a calculated field
Дата
Msg-id CAKFQuwbNdxYVZQysNtkft2cRC7RdSnbNDpeET5KyqNgHPFiwig@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Condition in a calculated field  (JORGE MALDONADO <jorgemal1960@gmail.com>)
Список pgsql-novice
On Tue, Sep 9, 2014 at 3:00 PM, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:
I just watched the documentation and did what you suggested but I am still getting the same error message. I did the following test, what is wrong?

HAVING 
  facturas.fce_valor_comercial > total

​It cannot see "total" because that alias is defined in the final select-list.  

As I said you have to repeat the expression.

HAVING
  facturas.fce_valor_comercial > sum(facsub.fce_valor_comercial)

 
WHERE clause is pre-grouping.

What you want is the HAVING clause - though you have to repeat the
expression (e.g., col > sum(...) ) as opposed to referring to it by name
(e.g., col > total).

http://www.postgresql.org/docs/devel/static/sql-select.html

David J.

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

Предыдущее
От: JORGE MALDONADO
Дата:
Сообщение: Re: Condition in a calculated field
Следующее
От: "Jake O'brien Fagan"
Дата:
Сообщение: Postgresql replication not starting after running pg_basebackup