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

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.

Good luck.



view thread (3+ messages)  latest in thread

Message-ID: <a55915760711191311s115535d5ofe9d0ebb99714b9b@mail.gmail.com>
Permalink:  ../a55915760711191311s115535d5ofe9d0ebb99714b9b@mail.gmail.com/
Also on:    postgresql.org/message-id/a55915760711191311s115535d5ofe9d0ebb99714b9b@mail.gmail.com

 · 

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: rdeleonp@gmail.com, luiz@planit.com.br
  Subject: Re: Aggregate question (Sum)
  In-Reply-To: <a55915760711191311s115535d5ofe9d0ebb99714b9b@mail.gmail.com>

* 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