| From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
|---|---|
| To: | robert(at)webtent(dot)com |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Division |
| Date: | 2005-11-04 17:46:02 |
| Message-ID: | 200511041846.02733.peter_e@gmx.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Robert Fitzpatrick wrote:
> I am having a problem gettig a percent via division. Below is the
> first part of my trigger function where pct returns 0.00, instead of
> the expected 0.50. If I try without dimensions to the numeric
> variable, I just get 0. What is the correct way to accomplish the
> percent?
You are dividing an integer by an integer, and if the first integer is 1
then the result is often 0. You need to use numeric for your noreps
variable.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Ftizpatrick | 2005-11-04 17:48:18 | Re: Division |
| Previous Message | Eliézer Madeira de Campos | 2005-11-04 17:42:04 | Missing seconds in a date (timestamp) |