Grouping By Part Of The Key

Moyeen Khan

Grouping By Part Of The Key
Hi Gurus
How can I group by part of the key? I have a table which has date/time
stamp and I want to total by date only.

Thanks for your help



Rodney KRick

Grouping By Part Of The Key
(in response to Moyeen Khan)
Hi,

try using the date function:

select date(ctime), count(*) from sysibm.systables group by date(ctime)

HTH.

Mit freundlichen Grüßen / Best regards,

Rodney Krick
Hänchen & Partner GmbH
Calwer Straße 1
D-71034 Böblingen




Moyeen Khan <[login to unmask email]>
Gesendet von: DB2 Data Base Discussion List <[login to unmask email]>
07.01.2003 15:56
Bitte antworten an
DB2 Data Base Discussion List <[login to unmask email]>


An
[login to unmask email]
Kopie

Thema
Grouping By Part Of The Key






Hi Gurus
How can I group by part of the key? I have a table which has date/time
stamp and I want to total by date only.

Thanks for your help



the DB2-L webpage at http://listserv.ylassoc.com. The owners of the list
can

Michael Ebert

Re: Grouping By Part Of The Key
(in response to Rodney KRick)
Use an inline view:

SELECT SUM(value), DateCol FROM
( SELECT value, DATE(TimestampCol) AS DateCol FROM yourtable ) T1
GROUP BY DateCol;

Dr. Michael Ebert
DB2 Database Administrator
aMaDEUS Data Processing
Erding / Munich, Germany



Hi Gurus
How can I group by part of the key? I have a table which has date/time
stamp and I want to total by date only.

Thanks for your help

Brian Goldberg

Re: Grouping By Part Of The Key
(in response to Michael Ebert)
In situations like this, table expressions work great. Here's an example:

SELECT
M.TMS_DATE,
COUNT (*) AS COUNT
FROM
(SELECT
SUBSTR (CHAR (CREATE_TMS), 1, 10) AS TMS_DATE
FROM
XXXXXXX.YYYYYYYY M) AS M
GROUP BY
M.TMS_DATE
ORDER BY
M.TMS_DATE
;

Brian



Moyeen Khan
<[login to unmask email] To: [login to unmask email]
YSLER.COM> cc: (bcc: BRIAN GOLDBERG/QVC)
Ext: NA Subject: Grouping By Part Of The Key
Sent by: DB2 Data
Base Discussion
List
<[login to unmask email]
LASSOC.COM>


01/07/2003 09:56
AM
Please respond to
DB2 Data Base
Discussion List






Hi Gurus
How can I group by part of the key? I have a table which has date/time
stamp and I want to total by date only.

Thanks for your help



the DB2-L webpage at http://listserv.ylassoc.com. The owners of the list
can



Abhijit Sinha

Re: Grouping By Part Of The Key
(in response to Brian Goldberg)
group by DATE(timestamp_column).

-----Original Message-----
From: Moyeen Khan [mailto:[login to unmask email]
Sent: Tuesday, January 07, 2003 9:57 AM
To: [login to unmask email]
Subject: Grouping By Part Of The Key


Hi Gurus
How can I group by part of the key? I have a table which has date/time
stamp and I want to total by date only.

Thanks for your help