Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL HELP

Re: SQL HELP

From: Alan D. Mills <alanmNOSPAM_at_uk.europe.mcd.mot.com>
Date: Fri, 21 Aug 1998 14:50:31 +0100
Message-ID: <6rjtua$foi$1@schbbs.mot.com>


see insets

--
Alan D. Mills

prochak_at_my-dejanews.com wrote in message <6rjqsm$7sc$1_at_nnrp1.dejanews.com>...
>In article <01bdccce$f9f9f840$2a822c95_at_pdcpm>,

>
>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);

It's not quite the same though is it? Using between implies equality as well which wasn't in the original SQL. However, I do take your point because it's more likely (from my experience) that equality want to be tested as well for date ranges. Especially if only dates are required and not dates with time stamps.

Actually, this raises another point. Assuming that BETWEEN is now the operator of choice then you will need to use TRUNC on the order_date column to ensure that dates matching date2 come out.

>
>-----== 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 - 08:50:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US