I have a simple query to filter out the due_date value is today.
SELECT *
FROM ORDER
WHERE DUE_DATE = CURRENT_DATE AND
ROWNUM <= 10
ORDER BY DUE_DATE ASC
However, even I have a bunch of order has due date as today, the query actually return 0 rows.
How come? Thanks in advance.
Sorry I forget to mention the DUE_DATE is of type Date
You need to either truncate your dates, as in
or use a ranged comparison, as in
The latter example may perform better because an index can be used (assuming you have an index on DUE_DATE). Of course, you could also add a function-based index on TRUNC(DUE_DATE) in which case either would likely perform equally well.
Share and enjoy.