Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: These WHERE clause are equal ?
I don't think so, the result should be the same on either,
but #2 might use an existing index (depending on the number
of rows in the table), whereas #1 will not use an index
I usually write:
select * from TBL_LOG
WHERE stamp_date BETWEEN TO_DATE('04-02-2002', 'dd-mm-yyyy')
AND TO_DATE('09-02-2002 23:59:59', 'dd-mm-yyyy hh24:mi:ss')
HTH Dieter
"R Chin" <rchin_at_ictgroup.com> schrieb im Newsbeitrag
news:a5gq04$gg5$1_at_reader2.panix.com...
> Are the WHERE clauses below equivalent ?
>
> stamp_date has time stamp (ie '02/08/2002 12:57:51 PM')
> and I don't care about the time.
>
> Case 1)
> select * from TBL_LOG
> where TRUNC(stamp_date) BETWEEN '04-FEB-2002' AND '09-FEB-2002'
>
> Case 2)
> select * from TBL_LOG
> stamp_date BETWEEN TO_DATE('04-FEB-2002') AND TO_DATE('09-FEB-2002') +
> .99999
>
>
> rowid comparison seems to match.
>
> Thanks
>
>
>
>
Received on Tue Feb 26 2002 - 18:10:05 CST