Re: ORACLE DATE IN WHERE CLAUSE PROBLEMS

From: John Kline <jkline_at_iconstl.net>
Date: 1995/06/30
Message-ID: <3t11il$7pj_at_server.icon-stl.net>#1/1


In article <DAz3zr.GJv_at_ddvictor.dundee.ATTGIS.COM>,

   Iain MacDonald <Iain.MacDonald_at_Dundee.NCR.COM> wrote:
>I have a variation on this request:
>
>SELECT or_bdate, count(*)
>FROM orders
>GROUP BY or_bdate;
>
>I had hoped to see a total of orders for each date, but instead I had a huge
>list
>of discrete time 'groups' - anyone overcome this?
>
>Iain MacDonald, WWIS, AT&T GIS (FP&S Scotland)

A "Date" column is stored with both the time and date components together. Thus when you group by a date column you are effectively grouping by "seconds". By your post I assume you want to group by "days". Change your selects to this:

SELECT or_bdate, count(*)
FROM orders
GROUP BY trunc (or_bdate);

TRUNC () by defaults truncates the time component. You can use different modifiers to the TRUNC function to group by week, month, quater, year,...,etc.

John Kline | .sig under construction jtkline_at_icon-stl.net | Received on Fri Jun 30 1995 - 00:00:00 CEST

Original text of this message