nPath Function Results Example | Teradata Vantage - nPath Results Example: Combine Values from One Row with Values from the Next Row - Analytics Database

Database Analytic Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-04-06
dita:mapPath
gjn1627595495337.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
jmh1512506877710
Product Category
Teradata Vantageā„¢

Input

The input table is clickstream, as in nPath Filters Example.

SQL Call

SELECT * FROM nPath (
  ON clickstream PARTITION BY userid ORDER BY userid, sessionid, clicktime
  USING
  Mode (OVERLAPPING)
  Pattern ('A.B')
  Symbols (TRUE AS A, TRUE AS B)
  Result (
    FIRST (sessionid OF A) AS sessionid,
    FIRST (pagetype OF A) AS pageid,
    FIRST (pagetype OF B) AS next_pageid
  )
) ORDER BY sessionid;

Output

sessionid pageid next_pageid
1 home view
1 view view
1 checkout view
1 checkout checkout
1 view checkout
1 view view
2 checkout view
2 home view
2 view view
2 view checkout