Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL HELP
In article <01bdccce$f9f9f840$2a822c95_at_pdcpm>,
"Philippe" <parnaud_at_yahoo.com> wrote:
> Use the TRUNC function :
>
> select count(order_id), trunc(order_date)
> from order_record
> where trunc(order_date) > date1
> and trunc(order_date) < date2
> group by trunc(order_date);
>
> HTH
>
Just don't over use it. Those truncates in the where clause may cause a big performance hit. The above query cannot use any index on the date field. You only need the truncate in the select and order by clauses:
select count(order_id), trunc(order_date)
from order_record
where order_date > date1
and order_date < date2
group by trunc(order_date);
and while we are here, why not use the BETWEEN operator, since that is really what you want (No performance difference, just easier to read)
select count(order_id), trunc(order_date)
from order_record
where order_date between date1 and date2
group by trunc(order_date);
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Fri Aug 21 1998 - 07:57:58 CDT
![]() |
![]() |