Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to compare NUMBER's
On Aug 8, 9:19 am, "Jimmy" <lofe..._at_yahoo.com.cn> wrote:
> Table t1 has two fields s1,s2 both with type NUMBER(9,3),
>
> After I exectue following sql,
> "SELECT s1, (s1-s2)/s2 FROM t1"
>
> result is:
> 000001, .872
> 000002, 0
>
> While executing "SELECT s1, (s1-s2)/s2 FROM t1 WHERE (s1-s2)/s2>0.5",
>
> result is:
> no rows effected.
>
> Why not "000001, .872"?
>
> I wonder what's wrong if I write the condition in WHERE clause as
> "(s1-s2)/s2>0.5"?
>
> Thanks in advance.
SQL> select banner from v$version;
BANNER
SQL>
SQL> create table t1 (s1 number(9,3), s2 number(9,3));
Table created.
SQL>
SQL> insert into t1 values(1, 0.534);
1 row created.
SQL> insert into t1 values(1, 1);
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL> SQL> column c2 format 0D999 SQL> SQL> select s1, (s1-s2)/s2 c2 from t1; S1 C2 ---------- ------ 1 0.873 1 0.000
SQL>
SQL> select s1, (s1-s2)/s2 c2 from t1 where (s1-s2)/s2 > 0.5;
S1 C2
---------- ------
1 0.873
So there's nothing wrong with the condition as it seems. What's your Oracle version? What's exact definition of your table, exact data in your table and exact statements you used (I couldn't get 0.872 for the second column with precision of 3?)
Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com
Received on Wed Aug 08 2007 - 06:25:43 CDT