| From: | David Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> |
|---|---|
| To: | JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> |
| Cc: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Condition in a calculated field |
| Date: | 2014-09-09 19:05:01 |
| Message-ID: | CAKFQuwbNdxYVZQysNtkft2cRC7RdSnbNDpeET5KyqNgHPFiwig@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
On Tue, Sep 9, 2014 at 3:00 PM, JORGE MALDONADO <jorgemal1960(at)gmail(dot)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.
>>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jake O'brien Fagan | 2014-09-11 21:30:27 | Postgresql replication not starting after running pg_basebackup |
| Previous Message | JORGE MALDONADO | 2014-09-09 19:03:47 | Re: Condition in a calculated field |