Home » SQL & PL/SQL » SQL & PL/SQL » -ve value problem in sql query...
-ve value problem in sql query... [message #20001] Tue, 23 April 2002 10:13 Go to next message
smith
Messages: 7
Registered: April 2002
Junior Member
Hi,

Here is my requirement.
Compare the result from both schemas. For example give me the difference only when two numbers are 5% different

Here are my schema's

SQL> select * from schema1.invoice;

NAME AMOUNT
--------------- ---------
sushi 100
Anuraag 100
Jayakumar 94
Jaya 95

SQL> select * from schema2.invoice;

NAME AMOUNT
--------------- ---------
sushi 85
Anuraag 95
jayakumar 100
Jaya 96

Here is the query i have written

select a.* from schema1.invoice a,schema2.invoice b
where (a.amount-b.amount)/100 >=0.05
and a.name=b.name;

NAME AMOUNT
--------------- ---------
Anuraag 100
sushi 100

The problem here is it's calculating the precentage
but it's not selecting the record where the name is "Jayakumar"
Because when it calculates the percentage becomes -ve value.

Could someone tell me how can i select that row also.

Thanks in advance,
Smith.
Re: -ve value problem in sql query... [message #20002 is a reply to message #20001] Tue, 23 April 2002 10:35 Go to previous message
smith
Messages: 7
Registered: April 2002
Junior Member
I got the answer.
We can use abs function to solve this problem.

Smith
Previous Topic: Spool command
Next Topic: Re: ORA:01839
Goto Forum:
  


Current Time: Fri Apr 26 15:44:05 CDT 2024