16.10 - Example 3: Find Paths to Checkout Page for Purchases Over $200 - 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 ('A*.C+.A*')
   SYMBOLS (productprice > 200 AND
   pagetype='checkout' AS C, true AS A)
   RESULT (FIRST(sessionid OF A) AS sessionid,
   ACCUMULATE (pagetype OF ANY(A,C)) AS path,
   AVG (productprice OF ANY(A,C)) AS totalsum)
) as dt ORDER BY dt.sessionid;

Output

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