I have this below simple query:
Select * from Table_A
where approved_date > NVL((Select Max(Last_Processed_Time) from Table_B),
TO_DATE('2021/04/19 11:13:44', 'yyyy/mm/dd hh24:mi:ss'))
If I run the query, it doesn't return any rows, but, it return records when I run the query as below:
Select * from Table_A
where approved_date > TO_DATE('2021/04/19 11:13:44', 'yyyy/mm/dd hh24:mi:ss')
I have to check Table_B record count, In my case, Table_B is empty. I am checking if Table_B is empty, and if it is empty, I will use a hardcoded date. so I am using NVL. Am I missing anything here?
If
(Select Max(Last_Processed_Time) from Table_B)
is greater than the largestapproved_date
intable_a
then you will filter out all the rows and the result set will be empty.Then you probably have rows where the
approved_date
is greater than 2021-04-19T11:13:44 but is not greater than the maximumlast_processed_time
intable_b
.