467,887 Members | 1,538 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,887 developers. It's quick & easy.

Very basic formatting question

Using db2 CLP I am trying to get the following SQL statement to
display "0.33". But, as you can see, it doesn't.

db2 =select round(float(1) / 3, 2) from sysibm.sysdummy1

1
------------------------
+3.30000000000000E-001

1 record(s) selected.

What on earth am I doing wrong?

Thanks,

\M

Jul 24 '07 #1
  • viewed: 3332
Share:
2 Replies
Desmodromic wrote:
Using db2 CLP I am trying to get the following SQL statement to
display "0.33". But, as you can see, it doesn't.

db2 =select round(float(1) / 3, 2) from sysibm.sysdummy1

1
------------------------
+3.30000000000000E-001

1 record(s) selected.
Try casting to DECIMAL.
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jul 24 '07 #2
On Tue, 24 Jul 2007 02:29:10 -0700, Desmodromic
<da*******@yahoo.com.auwrote:
>Using db2 CLP I am trying to get the following SQL statement to
display "0.33". But, as you can see, it doesn't.

db2 =select round(float(1) / 3, 2) from sysibm.sysdummy1

1
------------------------
+3.30000000000000E-001

1 record(s) selected.

What on earth am I doing wrong?

Thanks,

\M
What are you doing wrong? You are assuming that ROUND() chops off the
rounded zeros. It does indeed round them, it does not, however, remove
them.

Way around this is as Serge said, cast it afterwards: select
DECIMAL(round(float(1) / 3, 2), 3,2) from sysibm.sysdummy1

B.
Jul 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by hope | last post: by
3 posts views Thread by Mario Soto | last post: by
8 posts views Thread by Markus Pitha | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.