The nPath function populates the FrequentPaths input table with sequences that start with "A" and end with "C", using the Accumulate argument to output the full sequence.
CREATE VIEW nPath_output AS ( SELECT * FROM npath ( ON sequence_table PARTITION BY id ORDER BY datestamp Pattern ('itemA.itemAny*.itemC') Symbols (item='A' AS itemA, item='C' AS itemC, TRUE AS itemAny) Result (FIRST(id OF itemA) AS id, Accumulate (item OF ANY(itemA, itemAny, itemC)) AS path) Mode (NONOVERLAPPING) ) );
This query returns the following table:
SELECT * FROM nPath_output ORDER BY id;
id | path |
---|---|
1 | [A, B, C] |
3 | [A, D, C] |