pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Phillip Smith <phillips@weatherbeeta.com.au>
To: pgsql-sql@postgresql.org
Subject: Re: Select Maths
Date: Tue, 11 Jul 2006 10:30:21 +1000
Message-ID: <006f01c6a481$31b9e280$9b0014ac@ITPhil> (raw)

Example:

Funcation pqty(stock.code) calculates a value of 0 for a particular product.
This fails the last CASE that makes sure the pqty() value is greater than
our Usage Rate * Review Cycle - in this case is 3. But that is less than our
Minimum Order Qty (First CASE) and not a multiple of our Box Qty (Second
CASE)

Another example could be that pqty() calculates less than the Minimum Order
Qty (fails first CASE) so we raise it to the Minimum Order Qty, but that new
value could fail either or both of the second CASE's.

Minimum Order Qty = stock.purchase_unit
Box Qty = stock.box_qty

I guess a better way to word it is that because pqty() returns a calculated
value each time and I can't take that value and assign it to a variable,
then use that variable. If I was writing VB or similar I'd want something
like:

intPurchaseQty = pqty(stock.code)

CASE  WHEN intPurchaseQty < stock.purchase_unit THEN intPurchaseQty =
stock.purchase_unit

WHEN MOD(intPurchaseQty, stock.box_qty) > 0 THEN intPurchaseQty =
stock.box_qty * ROUND(CAST(intPurchaseQty AS DOUBLE PRECISION) /
stock.box_qty)

WHEN intPurchaseQty < (urate(stock.code) * creditors.review_cycle) THEN
intPurchaseQty = urate(stock.code) * creditors.review_cycle

END

COLUMN = intPurchaseQty AS "pqty",

I hope that makes it a lighter shade of mud!!

 

-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]
On Behalf Of Aaron Bono
Sent: Tuesday, 11 July 2006 02:36
To: Phillip Smith
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Select Maths


Can you provide example values and show where it is and is not working?  I
am not quite sure what you are trying to do here. 

-Aaron 

 



*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee.  If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments

view thread (8+ messages)  latest in thread

Message-ID: <006f01c6a481$31b9e280$9b0014ac@ITPhil>
Permalink:  ../006f01c6a481$31b9e280$9b0014ac@ITPhil/
Also on:    postgresql.org/message-id/006f01c6a481$31b9e280$9b0014ac@ITPhil

 · 

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: phillips@weatherbeeta.com.au
  Subject: Re: Select Maths
  In-Reply-To: <006f01c6a481$31b9e280$9b0014ac@ITPhil>

* 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