Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Why aren't these queries the same?
I'm going through a process of identifying our biggest I/O hogs and working with
the devleopers to fix them. One statement has us stumped. The original looks
like this
select count(*)
from scott.table_a
where (trunc(sysdate) - trunc(scott.table_a.mod_date) >= 12)
/
so what they are looking for are instances of mod_date that are 12 or more days old.
We re-wrote the query to look like this
select count(*)
from scott.table_a
where mod_date < (sysdate - 12)
/
but they don't return the same results.
I did confirm that trunc(sysdate) returned the same value as sysdate and trunc(scott.table_a.mod_date) returned the same value as scott.table_a.mod_date.
-- Ed Stevens (Opinions expressed do not necessarily represent those of my employer.)Received on Wed Mar 06 2002 - 16:43:04 CST
![]() |
![]() |