-- *** before: ***
-- a run of growing values was searched with LAG and a chain of
-- window functions, or in the application
-- *** in version 2016: ***
SELECT *
FROM city MATCH_RECOGNIZE (
PARTITION BY CountryCode
ORDER BY Population
MEASURES FIRST(up.Name) AS FromCity, LAST(up.Name) AS ToCity
PATTERN (up+)
DEFINE up AS up.Population > PREV(up.Population)
)
-- Support: Oracle 12c is the only one of the seven that has it (the
-- feature also exists in Db2, Snowflake and Trino). MySQL, PostgreSQL,
-- SQLite, MS SQL Server, Firebird and Access have no row pattern
-- recognition.