16.20 - nPath Range-Matching Example: Find Paths to Checkout Page for Purchases Over $200 - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ - NewSQL Engine Analytic Functions

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Release Date
July 2019
Content Type
Programming Reference
Publication ID
B035-1206-162K
Language
English (United States)

Input

The input table is aggregate_clicks, from LAG and LEAD Expressions Example: No Alias for Input Query.

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

sessionid path totalsum
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