sql - Nesting qualify statements in Teradata -
is possible "nest" qualify statements in teradata?
i have data looks this:
event_id = 1: user_id action_timestamp 971,134,265 17mar2010 20:16:56 739,071,748 17mar2010 22:19:59 919,853,934 18mar2010 15:47:49 919,853,934 18mar2010 15:55:21 919,853,934 18mar2010 16:01:20 919,853,934 18mar2010 16:01:48 919,853,934 18mar2010 16:04:52 472,665,603 20mar2010 18:23:58 472,665,603 20mar2010 18:24:07 472,665,603 20mar2010 18:24:26 .... event_id = 2: 971,134,265 17mar2069 20:16:56 739,071,748 17mar2069 22:19:59 919,853,934 18mar2069 15:47:49 919,853,934 18mar2069 15:55:21 919,853,934 18mar2069 16:01:20 919,853,934 18mar2069 16:01:48 919,853,934 18mar2069 16:04:52 472,665,603 20mar2069 18:23:58 472,665,603 20mar2069 18:24:07 472,665,603 20mar2069 18:24:26
for user 919,853,934, grab "18mar2010 16:04:52" action (the last 1 in first cluster of events).
i tried this, not grab right date:
select action_timestamp ,user_id ,event_id table ... qualify ( max(action_timestampt) on (partition user_id, event_id) = action_timestamp , min(action_timestamp) on (partition user_id) = action_timestamp )
this makes sense since max , min apply whole data, rather sequentially.
i tried 2 separate qualify statements min() part apply subset of data created max() part, errors.
this seems accomplish want:
select * (select * table ... qualify (max(action_date) on (partition user_id, event_id) = action_date) ) qualify ( min(a.action_date) on (partition a.user_id) = a.action_date )
Comments
Post a Comment