Re: Select Maths
От | Aaron Bono |
---|---|
Тема | Re: Select Maths |
Дата | |
Msg-id | bf05e51c0607070136he5519b9x96e97a73a6483a2a@mail.gmail.com обсуждение исходный текст |
Ответ на | Select Maths ("Phillip Smith" <phillips@weatherbeeta.com.au>) |
Ответы |
Re: Select Maths
|
Список | pgsql-sql |
On 7/7/06, Phillip Smith <phillips@weatherbeeta.com.au> wrote:
select 25 * round(cast(60 as double precision) / 25)
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)
В списке pgsql-sql по дате отправления: