pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Luiz K. Matsumura <luiz@planit.com.br>
To: Rodrigo De León <rdeleonp@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Aggregate question (Sum)
Date: Mon, 19 Nov 2007 21:17:26 -0200
Message-ID: <47421986.1020509@planit.com.br> (raw)
In-Reply-To: <a55915760711191311s115535d5ofe9d0ebb99714b9b@mail.gmail.com>
References: <4741F63A.6070500@planit.com.br>
	<a55915760711191311s115535d5ofe9d0ebb99714b9b@mail.gmail.com>

Hi Rodrigo, thanks for reply

Rodrigo De León wrote:
> On Nov 19, 2007 3:46 PM, Luiz K. Matsumura <luiz@planit.com.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.




view thread (3+ messages)

Message-ID: <47421986.1020509@planit.com.br>
Permalink:  ../47421986.1020509@planit.com.br/
Also on:    postgresql.org/message-id/47421986.1020509@planit.com.br

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: luiz@planit.com.br, rdeleonp@gmail.com
  Subject: Re: Aggregate question (Sum)
  In-Reply-To: <47421986.1020509@planit.com.br>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox