Code help needed to summarise table
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Code help needed to summarise table Expand / Collapse
Author
Message
Posted 3/17/2008 12:07:40 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 3/18/2008 5:26:39 AM
Posts: 2, Visits: 4
Hi,

I'm working with this table that has account numbers and event time stamps from call centre history logs. I want to be able to summarise the table to show the min and max timestamp for call (the example data shows two calls for account number 12345). Any ideas ?

Account Timestamp
12345 08:21:32 (call 1 start)
12345 08:21:35
12345 08:22:49
12345 08:23:00
12345 08:23:35 (call 1 end)
12345 12:59:32 (call 2 start)
12345 12:59:59
12345 13:02:17 (call 2 end)



Post #10962
Posted 3/17/2008 12:16:11 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 3/18/2008 5:26:39 AM
Posts: 2, Visits: 4
Forgot to say that there are other calls from other accounts in between the two calls in the example ...


Account Timestamp
12345 08:21:32 (call 1 start)
12345 08:21:35
12345 08:22:49
12345 08:23:00
12345 08:23:35 (call 1 end)

(other calls from other accounts)

12345 12:59:32 (call 2 start)
12345 12:59:59
12345 13:02:17 (call 2 end)
Post #10963
Posted 3/18/2008 1:31:20 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 11/12/2008 9:19:53 PM
Posts: 469, Visits: 463
What I don't understand is, just by looking at the data how can I say that call which started at 08:21:32 ended at 08:23:35 and not at
13:02:17 ? (I know some folks who can talk that long :o )
Post #10967
Posted 3/18/2008 6:19:22 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 11/25/2008 5:18:31 PM
Posts: 21, Visits: 88
Hi,

In work in a telco, and our data has a different format to what your describe. I agree with joe, I would expect to see some identifier for the call itself. So, with that in mind if you do have a call_id and the data looks something like this:

Account Timestamp call_id
12345 08:21:32 1
12345 08:21:35 1
12345 08:22:49 1
12345 08:23:00 1
12345 08:23:35 1
12345 12:59:32 2
12345 12:59:59 2
12345 13:02:17 2

then this SQL would create a few additional columns

SELECT T0.C0 AS acct_id
, T0.C1 AS call_id
, T2.Time_stamp AS time_exact
, T0.C2 AS time_min
, T1.C2 AS time_max
, T0.C3 AS element_id

FROM (
SELECT T0."Account" AS C0
,T0."call_id" AS C1
,MIN(T0."Time_stamp") AS C2
,COUNT(*) AS C3
FROM IPSHARE."TMANNS_tmp1" T0
GROUP BY T0."Account",
T0."call_id") T0
,(
SELECT T0."Account" AS C0
,T0."call_id" AS C1
,MAX(T0."Time_stamp") AS C2
FROM IPSHARE."TMANNS_tmp1" T0
GROUP BY T0."Account",T0."call_id") T1
,IPSHARE."TMANNS_tmp1" T2
WHERE (T0.C0 = T1.C0)
AND (T0.C1 = T1.C1)
AND (T1.C0 = T2."Account")
AND (T1.C1 = T2."call_id")
;


Apologies for the nasty formatting, it was partly auto generated SQL.

The data created by this query would be in the follwing format.;

acct_id call_id time_exact time_min time_max element_count
12345 1 08:21:32 08:21:32 08:23:35 5
12345 1 08:21:35 08:21:32 08:23:35 5
12345 1 08:22:49 08:21:32 08:23:35 5
12345 1 08:23:00 08:21:32 08:23:35 5
12345 1 08:23:35 08:21:32 08:23:35 5
12345 2 12:59:32 12:59:32 13:02:17 3
12345 2 12:59:59 12:59:32 13:02:17 3
12345 2 13:02:17 12:59:32 13:02:17 3



If you don't have a call_id or some way to identify the start of one call and the end of another, then I reckon you are screwed.

Enjoy, cheers!

Tim
Post #10980
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 6 ( 6 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 8:22pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.156. 10 queries. Compression Disabled.