Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Using Index to find row near value
Hi all,
I have a table with a TIMESTAMP column. Now I try to search the row where the TIMESTAMP of the row is less than a given value and the next TIMESTAMP in the table is greater than the given value. I can find this row with this query:
SELECT
*
FROM
(
SELECT
TS_START,
LEAD(TS_START) OVER (ORDER BY TS_START) NEXT_TS_START
FROM
TAB_TIME
)
WHERE
TS_START <= TO_TIMESTAMP('05.10.2006 14:24:35','DD.MM.YYYY HH24:MI:SS') AND
NEXT_TS_START >= TO_TIMESTAMP('05.10.2006 14:24:35','DD.MM.YYYY HH24:MI:SS')
But this results always in a full table scan. Is there a way I can get
oracle to use the index in the TIMESTAMP column? I don't know that
much about indexes but I think this should be possible.
Thanks Björn Received on Tue Mar 13 2007 - 02:38:14 CDT