On executing the query
select * from employee
where salary <= previous_salary
I'm getting a wrong output as follows (it's returning the entire table). I'm doing this in Oracle Application Express Edition
ID NAME SALARY DEPT PREVIOUS_SALARY
1 nadeem 1000 10 1500
2 kutu 1000 10 1500
3 aisha 1500 20 500
4 aisha 1500 20 500
and on executing this query
select * from employee
where salary >= previous_salary
I get no data found.
You've probably used a CHAR or VARCHAR2 type for the SALARY and PREVIOUS_SALARY columns.
When compared as strings, the data should work as you claim it does.
If you change the columns containing numbers to a numeric type, then the numeric comparisons will work as you intended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With