By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,514 Members | 1,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,514 IT Pros & Developers. It's quick & easy.

Very basic formatting question

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.