Message-Id: <10739.126469@fatcity.com> From: "Oweson Flynn" Date: Fri, 12 Jan 2001 10:39:27 +0200 Subject: Re: SQL Code This is a multi-part message in MIME format. ------=_NextPart_000_0111_01C07C83.EFC37CE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable SQL CodeHi Kevin, What about something like=20 SELECT=20 COUNT(*),=20 Code,=20 TO_CHAR( Date_Stamp, 'HH24' ) Hour FROM Table_Name GROUP BY Code,=20 TO_CHAR( Date_Stamp, 'HH24' ) Hour; It might take some processing to do the grouping by the To_Char (which give= s the hour), but it should work. Regards Oweson Flynn ------------------------------------------------------------------ Certified Oracle DBA The Flynn Consultancy Tel: 082-600-7-006 Fax: (011) 782-9313 EMail: oef@icon.co.za ----- Original Message -----=20 From: Naik, Kevin K=20 To: Multiple recipients of list ORACLE-L=20 Sent: Friday, January 12, 2001 8:55 AM Subject: SQL Code Hi All,=20 I have an interesting problem, lets say I have a table with 2 fields, one= with a code, and the other with a full datestamp, -+ 8 million records. What will the SQL code be to query this table, to show the result - the c= ount of all codes that occur between every hour for the day, ie 5 counts of code type a, 6 of type b etc, between 01h00 and 02h00=20 7 counts of type a, 8 of b etc, between 02h00 and 03h00 etc etc etc=20 Any ideas anybody ?=20 Thanx=20 Kevin N=20 ______________________________________________ Disclaimer and confidentiality note Everything in this e-mail and any attachments relating to the official bu= siness of Standard Bank Investment Corporation (Stanbic) is proprietary to = the company. It is confidential, legally privileged and protected by law. S= tanbic does not own and endorse any other content. Views and opinions are t= hose of the sender unless clearly stated as being that of Stanbic.=20 The person addressed in the e-mail is the sole authorised recipient. Plea= se notify the sender immediately if it has unintentionally reached you and = do not read, disclose or use the content in any way. Stanbic can not assure that the integrity of this communication has been = maintained nor that it is free of errors, virus, interception or interferen= ce. _______________________________________________ ******************************************************************** This message may contain information which is confidential and subject to l= egal privilege. If you are not the intended recipient, you may not peruse, = use, disseminate, distribute or copy this message. If you have received thi= s message in error, please notify the sender immediately by email, facsimil= e or telephone and return and/or destroy the original message. ******************************************************************* ------=_NextPart_000_0111_01C07C83.EFC37CE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable SQL Code
Hi Kevin,
 
What about something like
SELECT
   COUNT(*),
   Code,
   TO_CHAR( Date_Stamp, 'HH24' ) Hour<= /DIV>
FROM
  Table_Name
GROUP BY
   Code,
   TO_CHAR( Date_Stamp, 'HH24' ) Hour;=
 
It might take some processing to do the grouping by the To_Char (which= g ives the hour), but it should work.
 
Regards
Oweson=20 Flynn
------------------------------------------------------------------=
Certified=20 Oracle DBA
The Flynn Consultancy
Tel: 082-600-7-006
Fax: (011)=20 782-9313
EMail: oef@icon.co.za
----- Original Message -----
Fro= m:=20 Na= ik, Kevin=20 K
To: Multiple recipients of list ORACLE-L= =20
Sent: Friday, January 12, 2001 8:5= 5=20 AM
Subject: SQL Code

Hi All,

I have an interesting problem, lets say I have a table = with 2=20 fields, one with a code, and the other with a full datestamp, -+ 8 millio= n=20 records.

What will the SQL code be to query this table, to show = the=20 result - the count of all codes that occur between every hour for the day= ,=20 ie

5 counts of code type a, 6 of type b etc, between 01h00= and=20 02h00
7 counts of type a, 8 of b etc, between 0= 2h00=20 and 03h00 etc etc etc

Any ideas anybody ?
Thanx=20
Kevin N

______________________________________________

Disclaimer = and=20 confidentiality note

Everything in = this e-mail=20 and any attachments relating to the official business of Standard Bank=20 Investment Corporation= (Stanbic) is proprietary to the compan= y. It is=20 confidential, legally privileged and protected by law. Stanbic does not own=20 and endorse any other content. Views and opinions are those of the sender= unless clearly stated as being that of Stanbic.

The person add= ressed in the=20 e-mail is the sole authorised recipient. Please notify the sender immedia= tely=20 if it has unintentionally reached you and do not read, disclose or use th= e=20 content in any way.

Stanbic can not assure that the integrity of this communication has be= en=20 maintained nor that it is free of errors, virus, interception or=20 interference.

          &nbs= p;  _______________________________________________



********************************************************************

This message may contain information which is confidential and subject to l= egal privilege. If you are not the intended recipient, you may not peruse, = use, disseminate, distribute or copy this message. If you have received thi= s message in error, please notify the sender immediately by email, facsimil= e or telephone and return and/or destroy the original message.