Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: simple sql problem

RE: simple sql problem

From: Jacques Kilchoer <Jacques.Kilchoer_at_quest.com>
Date: Tue, 31 Jul 2001 09:47:39 -0700
Message-ID: <F001.0035A64A.20010731095232@fatcity.com>

> -----Original Message-----
> From: Viraj Luthra [mailto:viraj999_at_lycos.com]
>

>  No, I mean, if (x+y) < 1, that is a value of .92 which it 

> prints out, but I want it to print out like, 0.92, that is a
> "0." is concatenateed to the result.
>
> therefore, when i have,
>
> select x+y from blah
>
> I should get 90 when the value is really 90
> and I should get 0.92 when the value is really .92

Here is a starting point to help you.

  1. Read the manual on the following functions: sign decode to_char abs
  2. Look at the example below SQL> select   2    x, y, x + y as x_plus_y,   3    decode (sign (abs (x + y) - 1),   4            -1, to_char (x + y, '0.99'),   5            to_char (x + y, '99')   6           ) as formatted_x_plus_y   7   from t ;

         X          Y   X_PLUS_Y FORMA
---------- ---------- ---------- -----

        .7         .3          1   1
       -.4        1.8        1.4   1
        .2        .16        .36  0.36
        13         65         78  78
       -20      -16.2      -36.2 -36
         1       -1.4        -.4 -0.40
        34        -34          0  0.00


7 rows selected.



Jacques R. Kilchoer
(949) 754-8816
Quest Software, Inc.
8001 Irvine Center Drive
Irvine, California 92618
U.S.A.
http://www.quest.com Received on Tue Jul 31 2001 - 11:47:39 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US