Beyond Analytics: MODEL or MATCH_RECOGNIZE

Analytic functions are powerful and efficient, but sometimes they just aren’t enough. When you try analytics and they alone don’t solve the problem, it’s time to think about the MODEL clause – or upgrade to 12c and use MATCH_RECOGNIZE. All three can use partitions and ordering for simpler, more efficient processing. To illustrate, here’s a […]

Down with Firefox

Warning: this post is not technical and it is not about Oracle. Brendan Eich recently resigned under pressure from his job as CEO of Mozilla, the makers of Firefox. The reason given was a campaign contribution that Mr. Eich made in 2008. The State of California has the “referendum”: a proposition is submitted to a […]

Overlapping ranges with priority

A few years ago, Alberto Dell’Era blogged about product prices with overlapping date ranges; “on an overlapping range, the strongest priority (lower number) wins.” His analysis, explanation and solution are all excellent. I’m revisiting the subject to suggest a few improvements (and mention MATCH_RECOGNIZE yet again). To explain more easily, Alberto uses letters (a,b,c,d,e) instead […]

Merging contiguous date ranges

Last time I wrote about finding gaps in date ranges: this post is about merging date ranges that “meet”. This is a frequent question; the answer applies to any ranges, not just dates. As a reminder, I consider ranges to “meet” when the end value of one record is equal to the start value of […]

Gaps in Date Ranges: when are you free?

Calculating “free time” in Calendars is a very common task. Did you know it can be done by a SQL statement less than 100 bytes long? This post pays homage to an incredibly neat and concise use of analytic functions. The Question “Free time” in a Calendar means the unused time slots between events; in […]

SQL for date ranges, gaps and overlaps

There are lots of questions and posts on the Web about data with date ranges. It’s harder than it seems to design tables with start and end dates, to avoid overlaps or even to write SQL to find gaps or overlaps. I’m writing this post to get some basic ideas straight and to make myself […]

12c MATCH_RECOGNIZE and the “start of group” method

Please don’t think this post is “just” about MATCH_RECOGNIZE. I am going to present the “start of group” method as demonstrated by Timur Akhmadeev and Solomon Yakobson. This is a powerful use of analytics to group data based on comparisons between adjacent rows. It’s a technique worth knowing while waiting for 12c, when the MATCH_RECOGNIZE […]

12c MATCH_RECOGNIZE: Grouping sequences

The Tabibitosan method by Aketi Jyuuzou is a very clever and efficient way to group rows with consecutive values. When it solves the problem, it can’t be beat — unless you have 12c. This method is worth explaining in its own right, so I’ll do my best; then I’ll make it easier with the MATCH_RECOGNIZE […]

Database 12c MATCH_RECOGNIZE: Read all about it

I plan to update this post as new information appears on the Web. Last update: 2014/03/04. The MATCH_RECOGNIZE clause is documented here > SQL Language Reference: row_pattern_clause and explained here > Data Warehousing Guide: SQL for Pattern Matching The number one source of information is Keith Laker. His post “Sessionization with 12c SQL pattern matching […]