1.1 - 8.10 - nPath Example: Sessions that Checked 3-6 Products - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Teradata Vantage
Release Number
Release Date
October 2019
Content Type
Programming Reference
Publication ID
English (United States)

This example finds the data for sessions that checked three to six products.

For sessions where the user checked between three and six products (exclusive), return the names of the most and least expensive products, the maximum price of the most expensive product, and the minimum price of the least expensive product.

SQL Call

SELECT * FROM NPath@coprocessor (
  ON aggregate_clicks PARTITION BY sessionid ORDER BY clicktime
    Symbols(pagetype = 'home' AS H, pagetype='checkout' AS C,
            pagetype<>'home' AND pagetype<>'checkout' AS D)
    Result(first(sessionid of C) AS sessionid,
           max_choose(productprice, productname of C) AS most_expensive_product,
           max(productprice of C) AS max_price,
           min_choose(productprice, productname of C) AS least_expensive_product,
           min(productprice of C) AS min_price)
) AS dt;


 sessionid most_expensive_product max_price least_expensive_product min_price 
 --------- ---------------------- --------- ----------------------- --------- 
         5 cellphones                 600.0 bookcases                   150.0

Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.