BETWEEN with reversed range won’t work

I’ve found this strange example in Roopesh Ramklass book. According to him, it may work very well, but it won’t actually. See below

BETWEEN requires two values to specify the range. If an older date will be specified first, then no rows will be selected as shown below

 

But, if you exchange those values and make the earlier date first in BETWEEN clause, then it will return data

 

So, Roopesh Ramklass – it is just another typo in your book. You may want to correct it for your next book release

It is not enough for value 24-JUL-1996 to fall between the row’s HIRE_DATE column value plus 30 days and the date literal 07-JUN-1996.

It also must satisfy other rules for BETWEEN clause.

It is so obvious because 24-JUL-1996 is older date than 07-JUN-1996

 

 

Leave a comment

Your email address will not be published. Required fields are marked *