I have a query that groups rows together by two specific ids, and orders them by a action date. Along with this, a string of if the action date was added or removed is included.
I'd like to identify result sets that follow a pattern other than 'added' -> 'removed' -> ect. such as 'added' -> 'removed' -> 'added' -> 'added'.
If this was a set of data grouped together, I'd like to identify that as a pattern.
For example, I can use this query
select id_a , id_b, string_agg(action_key, ', ') as agg_field from test_table
group by id_a, id_b, link_type
order by agg_field desc
to get the column agg_field column as
'added, removed, added, added, removed'
but I'm not sure how to identify that result set in the group by as compared to
'added, removed, added, removed'
