vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| The following bug has been logged online: Bug reference: 3475 Logged by: vasile Email address: vasile.halosta@gmail.com PostgreSQL version: 8.2.4 Operating system: Centos 4.4 Description: SQL: 7/2 = 3 Details: When you divide 2 int the result is also int, is truncated: On pgsql: pg=# select 7/2; ?column? ---------- 3 (1 row) I know in c when you have to int operator the result is also int, but I think this is not a good idea in SQL. ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org |
| ||||
| On Fri, Jul 20, 2007 at 07:34:59AM +0000, vasile wrote: > > The following bug has been logged online: > > Bug reference: 3475 > Logged by: vasile > Email address: vasile.halosta@gmail.com > PostgreSQL version: 8.2.4 > Operating system: Centos 4.4 > Description: SQL: 7/2 = 3 > Details: > > When you divide 2 int the result is also int, is truncated: > > On pgsql: > pg=# select 7/2; > ?column? > ---------- > 3 > (1 row) > > > I know in c when you have to int operator the result is also int, but I > think this is not a good idea in SQL. That's what you get for integer division. If you want a floating point one, use: postgres=> select 7::float/2; ?column? ---------- 3.5 (1 row) //Magnus ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |
| Thread Tools | |
| Display Modes | |
|
|