From: | Aaron Bingham <bingham(at)cenix-bioscience(dot)com> |
---|---|
To: | Jiří Němec <konference(at)menea(dot)cz> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Duplicate counting |
Date: | 2005-01-20 13:49:36 |
Message-ID: | 41EFB6F0.8010204@cenix-bioscience.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Jiří Němec wrote:
> Hello all,
>
> I wrote a function which counts price of product from retail price and
> discount. It works. But I need to count price with tax of same
> product. The best way is to use counted price and add only a tax. I
> would like to do by this way:
>
> SELECT count_price(retail, discount) AS price, count_price_tax(price,
> tax) FROM foo.
>
> But PostgreSQL reports that "price" column doesn't exist. It doesn't
> exist, but is counted by first calling "count_price()" function.
>
> Is there some way how I shouldn't count these prices twice and use
> just counted price?
It's not quite clear to me what count_price and count_price_tax are
supposed to do. Does count_price_tax return the equivalent of
price*(1.0+tax) (or maybe price*tax)? If so, one way to do it is to use
a sub-query like this:
SELECT price, count_price_tax(price, tax) FROM (SELECT
count_price(retail, discount) AS price, tax FROM foo) AS bar;
--
--------------------------------------------------------------------
Aaron Bingham
Application Developer
Cenix BioScience GmbH
--------------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Frank D. Engel, Jr. | 2005-01-20 13:55:15 | Re: Best Linux Distribution |
Previous Message | Alban Hertroys | 2005-01-20 13:48:40 | How to manually insert an UTF-8 character into an SQL statement? |