16.10 - Example 2: Find Sessions That Start at Home Page and Visit Page1 - Teradata Database

Teradata Analytic Functions

prodname
Teradata Database
vrm_release
15.10
16.10
created_date
November 2017
category
Programming Reference
featnum
B035-1206-151K

SQL-MapReduce Call

SELECT * FROM NPATH (
   ON aggregate_clicks
   PARTITION BY sessionid
   ORDER BY clicktime
   USING
   MODE (nonoverlapping)
   PATTERN ('^H.A*.P1.A*')
   SYMBOLS (pagetype='home' AS H, pagetype='page1' AS P1, TRUE AS A)
   RESULT (FIRST(sessionid OF A) AS sessionid,
   ACCUMULATE (pagetype OF ANY(H,P1,A)) AS path)
) as dt ORDER BY dt.sessionid;

Output

nPath Range-Matching Example 2 Output Table
sessionid path
1 [home, home1, page1, home, home1, page1, home, home, home, home1, page1, checkout, home, home, home, home, home, home, home, home, home]
2 [home, home, home, home, home, home, home, home, home, home1, page1, checkout, checkout, home, home]
3 [home, home, home, home, home, home, home, home, home1, page1, home, home1, page1, home]
4 [home, home, home, home, home, home, home1, home1, home1, page1, page1, page1]
5 [home, home, home, home, home1, home1, home1, page1, page1, page1, page2, page2, page2, checkout, checkout, checkout, page2, page2, page2]