Skip to content

Instantly share code, notes, and snippets.

@ujnak
Created October 17, 2023 02:52
Show Gist options
  • Save ujnak/907f71153920f144f71a70fd9c6cd874 to your computer and use it in GitHub Desktop.
Save ujnak/907f71153920f144f71a70fd9c6cd874 to your computer and use it in GitHub Desktop.
MATCH_RECOGNIZE句を含んだSQLのサンプル
select mr_rt.*
from mrec_request_transitions_v
match_recognize(
partition by request_id
order by transition_date
measures
count(*) as cnt,
classifier() as cls,
match_number() as mno
all rows per match
after match skip to last p
pattern ( (r s){2,} a p )
define
r as r.status = 'REJECTED'
,s as (s.status = 'SUBMITTED' and amount > prev(amount))
,a as a.status = 'APPROVED'
,p as p.status = 'PAID'
) mr_rt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment