Home » SQL & PL/SQL » SQL & PL/SQL » Problem in number format mask (merged)
Problem in number format mask (merged) [message #210507] Thu, 21 December 2006 02:41 Go to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member

Hii All

I have a problem in my query

that i want to display all my number in a mask of appearing 3 decimal number after the point

eg

12.33     12.330
12.3333   12.333
12.3      12.300
12        12.000


Thanks for every one helped and helping me

Re: problem in number format mask [message #210510 is a reply to message #210507] Thu, 21 December 2006 02:49 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
with mytable as (select 12.33   num from dual union all
                 select 12.3333 num from dual union all
                 select 12.3    num from dual union all
                 select 12      num from dual)
select to_char(trunc(num,3),'99.000') from mytable
Format Mask again [message #210543 is a reply to message #210507] Thu, 21 December 2006 04:49 Go to previous messageGo to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member

Hii all


please lets see this query

select to_char ('54.33','99.999') from dual

which results 54.330

and also see this
select to_char ('54','99.999') from dual

which results 54.000

i want if the number is not having decimal points be displayed
as it self as the result will be 54



can i do that

thanks for everyone helped and helping me
Re: Format Mask again [message #210561 is a reply to message #210543] Thu, 21 December 2006 05:47 Go to previous message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
One solution might look like this:
SELECT DECODE(SIGN(TRUNC(&a) - &a), 0, TO_CHAR(&a, '99'), 
                                       TO_CHAR(&a, '99.999')
             )
 FROM dual;
Previous Topic: few condition to be met out of many conditions
Next Topic: about materialised view
Goto Forum:
  


Current Time: Sat Dec 03 22:18:56 CST 2016

Total time taken to generate the page: 0.04188 seconds