17.10 - nPath範囲一致の例: 購入金額が$200を超えるチェックアウト ページのパスを検索 - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Advanced SQL Engine分析関数

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
2021年7月
Content Type
プログラミング リファレンス
Publication ID
B035-1206-171K-JPN
Language
日本語 (日本)

入力

入力テーブルは、LAG式とLEAD式の例: 入力問合わせの別名なしによるaggregate_clicksです。

SQL-MapReduce呼び出し

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;

出力

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