Re: Aggregate question (Sum)

From: "Luiz K(dot) Matsumura" <luiz(at)planit(dot)com(dot)br>
To: Rodrigo De León <rdeleonp(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Aggregate question (Sum)
Date: 2007-11-19 23:17:26
Message-ID: 47421986.1020509@planit.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Rodrigo, thanks for reply

Rodrigo De León wrote:
> On Nov 19, 2007 3:46 PM, Luiz K. Matsumura <luiz(at)planit(dot)com(dot)br> wrote:
>
>> If someone can give me some hint I will apreciate.
>>
>
> This is more of a normalization problem. See:
>
> http://www.deeptraining.com/litwin/dbdesign/FundamentalsOfRelationalDatabaseDesign.aspx
>
> and lookup Third Normal Form.
>
> You have a calculated total for each order, so I assume there's a
> price for every product. You should join order_item to whichever table
> has the individual cost for each product and multiply it by
> order_item.qty.
>
>
Ok, the example is a simplified scenario.
In some cases we have discount on order that can't be 'distributed' on
the itens.
For example:

Item Qty ValueUnity item_total (calculated)
1 5 1.01 5.05
2 6 1.01 6.06

The total for itens is 11.11 but we make a discount of 0.01 , then the
value of order is now 11.10
This 0.01 of discount can't be aplied on any "ValueUnity" because the
precision is 2 decimals.
We can have too other calculations over this values (like taxes) so in
my case isn't so simple to
determine the final value of the order just summing the value of the itens.

Anyway, thanks again...

--
Luiz K. Matsumura
Plan IT Tecnologia Informática Ltda.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Otniel Michael 2007-11-20 09:21:33 Run Function With First Priority
Previous Message Rodrigo De León 2007-11-19 21:11:39 Re: Aggregate question (Sum)