1. select empno from emp where employed_date < sysdate -60 order by employed_date;
2. select empno from emp where employed_date < sysdate -60;
When I run statement 1, I get the right results, which give me all empno hired 2 months ago.
But statement number 2 returns record of empno hired one month ago. Seems like the where clause does not work properly here.
SQL> select id from emp where dt < sysdate-60;
Press Enter to Continue...
ID
---------
5
6
7
SQL> select id from emp where dt<sysdate-60 order by dt;
Press Enter to Continue...
ID
---------
7
6
5
If you are still getting the problem and the issue is with dates at the border, try using the TRUNC function on the date so that the time part is not checked.
If it still doesn't work, lemme know and gimme a few test cases that ain't working at your end.
Bookmarks