From: | "Aaron Bono" <postgresql(at)aranya(dot)com> |
---|---|
To: | "Phillip Smith" <phillips(at)weatherbeeta(dot)com(dot)au> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Select Maths |
Date: | 2006-07-07 08:36:53 |
Message-ID: | bf05e51c0607070136he5519b9x96e97a73a6483a2a@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 7/7/06, Phillip Smith <phillips(at)weatherbeeta(dot)com(dot)au> wrote:
>
> Same SELECT query as before, different area of it… I have a function that
> calculates the recommended purchase order quantity for a stock item based
> off various other values and functions:
>
> pqty(stock.code) AS "pqty"
>
>
>
> This needs to be rounded up / down to the nearest multiple of the *purchase
> unit* quantity for that product – It's Friday afternoon and my head has
> refused to help me work out the maths all afternoon!
>
>
>
> Example:
>
> Pqty = 60
>
> Purchase Unit = 25
>
> Pqty needs to be rounded down to 50.
>
>
>
> I guess I'm also asking if I should do this in the Pqty function or in the
> SELECT query to optimize the result?
>
select 25 * round(cast(60 as double precision) / 25)
From | Date | Subject | |
---|---|---|---|
Next Message | Aaron Bono | 2006-07-07 08:44:05 | Re: Select CASE Concatenation |
Previous Message | Aaron Bono | 2006-07-07 08:32:33 | Re: Alternative to serial primary key |