<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – MATCH clause</title>
    <link>/en/sql-reference/statements/select/match-clause/</link>
    <description>Recent content in MATCH clause on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/sql-reference/statements/select/match-clause/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Sql-Reference: Event series pattern matching</title>
      <link>/en/sql-reference/statements/select/match-clause/event-series-pattern-matching/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/statements/select/match-clause/event-series-pattern-matching/</guid>
      <description>
        
        
        &lt;p&gt;The SQL &lt;a href=&#34;../../../../../en/sql-reference/statements/select/match-clause/#&#34;&gt;MATCH clause&lt;/a&gt; syntax lets you screen large amounts of historical data in search of event patterns. You specify a pattern as a regular expression and can then search for the pattern within a sequence of input events. MATCH provides subclauses for analytic data partitioning and ordering, and the pattern matching occurs on a contiguous set of rows.&lt;/p&gt;
&lt;p&gt;Pattern matching is particularly useful for clickstream analysis where you might want to identify users&#39; actions based on their Web browsing behavior (page clicks). A typical online clickstream funnel is:&lt;/p&gt;
&lt;p&gt;Company home page -&amp;gt; product home page -&amp;gt; search -&amp;gt; results -&amp;gt; purchase online&lt;/p&gt;
&lt;p&gt;Using this clickstream funnel, you can search for a match on the user&#39;s sequence of web clicks and identify that user:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Landed on the company home page&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Navigated to the product page&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ran a search&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Clicked a link from the search results&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Made a purchase&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;clickstream-funnel-schema&#34;&gt;Clickstream funnel schema&lt;/h2&gt;
&lt;p&gt;The examples in this topic use this clickstream funnel and the following &lt;code&gt;clickstream_log&lt;/code&gt; table schema:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE clickstream_log (
  uid INT,             --user ID
  sid INT,             --browsing session ID, produced by previous sessionization computation
  ts TIME,             --timestamp that occurred during the user&amp;#39;s page visit
  refURL VARCHAR(20),  --URL of the page referencing PageURL
  pageURL VARCHAR(20), --URL of the page being visited
  action CHAR(1)       --action the user took after visiting the page (&amp;#39;P&amp;#39; = Purchase, &amp;#39;V&amp;#39; = View)
);

INSERT INTO clickstream_log VALUES (1,100,&amp;#39;12:00&amp;#39;,&amp;#39;website1.com&amp;#39;,&amp;#39;website2.com/home&amp;#39;, &amp;#39;V&amp;#39;);
INSERT INTO clickstream_log VALUES (1,100,&amp;#39;12:01&amp;#39;,&amp;#39;website2.com/home&amp;#39;,&amp;#39;website2.com/floby&amp;#39;, &amp;#39;V&amp;#39;);
INSERT INTO clickstream_log VALUES (1,100,&amp;#39;12:02&amp;#39;,&amp;#39;website2.com/floby&amp;#39;,&amp;#39;website2.com/shamwow&amp;#39;, &amp;#39;V&amp;#39;);
INSERT INTO clickstream_log values (1,100,&amp;#39;12:03&amp;#39;,&amp;#39;website2.com/shamwow&amp;#39;,&amp;#39;website2.com/buy&amp;#39;, &amp;#39;P&amp;#39;);
INSERT INTO clickstream_log values (2,100,&amp;#39;12:10&amp;#39;,&amp;#39;website1.com&amp;#39;,&amp;#39;website2.com/home&amp;#39;, &amp;#39;V&amp;#39;);
INSERT INTO clickstream_log values (2,100,&amp;#39;12:11&amp;#39;,&amp;#39;website2.com/home&amp;#39;,&amp;#39;website2.com/forks&amp;#39;, &amp;#39;V&amp;#39;);
INSERT INTO clickstream_log values (2,100,&amp;#39;12:13&amp;#39;,&amp;#39;website2.com/forks&amp;#39;,&amp;#39;website2.com/buy&amp;#39;, &amp;#39;P&amp;#39;);
COMMIT;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Here&#39;s the clickstream_log table&#39;s output:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM clickstream_log;
 uid | sid |    ts    |        refURL        |       pageURL        | action
-----+-----+----------+----------------------+----------------------+--------
   1 | 100 | 12:00:00 | website1.com         | website2.com/home    | V
   1 | 100 | 12:01:00 | website2.com/home    | website2.com/floby   | V
   1 | 100 | 12:02:00 | website2.com/floby   | website2.com/shamwow | V
   1 | 100 | 12:03:00 | website2.com/shamwow | website2.com/buy     | P
   2 | 100 | 12:10:00 | website1.com         | website2.com/home    | V
   2 | 100 | 12:11:00 | website2.com/home    | website2.com/forks   | V
   2 | 100 | 12:13:00 | website2.com/forks   | website2.com/buy     | P
(7 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;This example includes the OpenText™ Analytics Database &lt;a href=&#34;../../../../../en/sql-reference/functions/match-and-search-functions/match-clause-functions/#&#34;&gt;MATCH clause functions&lt;/a&gt; to analyze users&#39; browsing history over website2.com. It identifies patterns where the user performed the following tasks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Landed on website2.com from another web site (Entry)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Browsed to any number of other pages (Onsite)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Made a purchase (Purchase)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the following statement, pattern P (&lt;code&gt;Entry Onsite* Purchase&lt;/code&gt;) consist of three event types: Entry, Onsite, and Purchase. When the database finds a match in the input table, the associated pattern instance must be an event of type Entry followed by 0 or more events of type Onsite, and an event of type Purchase&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT uid,
       sid,
       ts,
       refurl,
       pageurl,
       action,
       event_name(),
       pattern_id(),
       match_id()
FROM clickstream_log
MATCH
  (PARTITION BY uid, sid ORDER BY ts
   DEFINE
     Entry    AS RefURL  NOT ILIKE &amp;#39;%website2.com%&amp;#39; AND PageURL ILIKE &amp;#39;%website2.com%&amp;#39;,
     Onsite   AS PageURL ILIKE     &amp;#39;%website2.com%&amp;#39; AND Action=&amp;#39;V&amp;#39;,
     Purchase AS PageURL ILIKE     &amp;#39;%website2.com%&amp;#39; AND Action = &amp;#39;P&amp;#39;
   PATTERN
     P AS (Entry Onsite* Purchase)
   ROWS MATCH FIRST EVENT);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In the output below, the first four rows represent the pattern for user 1&#39;s browsing activity, while the following three rows show user 2&#39;s browsing habits.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt; uid | sid |    ts    |        refurl        |       pageurl        | action | event_name | pattern_id | match_id
-----+-----+----------+----------------------+----------------------+--------+------------+------------+----------
   1 | 100 | 12:00:00 | website1.com         | website2.com/home    | V      | Entry      |          1 |        1
   1 | 100 | 12:01:00 | website2.com/home    | website2.com/floby   | V      | Onsite     |          1 |        2
   1 | 100 | 12:02:00 | website2.com/floby   | website2.com/shamwow | V      | Onsite     |          1 |        3
   1 | 100 | 12:03:00 | website2.com/shamwow | website2.com/buy     | P      | Purchase   |          1 |        4
   2 | 100 | 12:10:00 | website1.com         | website2.com/home    | V      | Entry      |          1 |        1
   2 | 100 | 12:11:00 | website2.com/home    | website2.com/forks   | V      | Onsite     |          1 |        2
   2 | 100 | 12:13:00 | website2.com/forks   | website2.com/buy     | P      | Purchase   |          1 |        3
(7 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/statements/select/match-clause/#&#34;&gt;MATCH clause&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/match-and-search-functions/match-clause-functions/#&#34;&gt;MATCH clause functions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
  </channel>
</rss>
