Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 24th, 2007, 10:35 AM
Desmodromic
Guest
 
Posts: n/a
Default 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

  #2  
Old July 24th, 2007, 11:45 AM
Serge Rielau
Guest
 
Posts: n/a
Default Re: Very basic formatting question

Desmodromic wrote:
Quote:
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
  #3  
Old July 25th, 2007, 02:15 PM
Brian Tkatch
Guest
 
Posts: n/a
Default Re: Very basic formatting question

On Tue, 24 Jul 2007 02:29:10 -0700, Desmodromic
<davies_ms@yahoo.com.auwrote:
Quote:
>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.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles