(Postgre)SQL: markov.sql: Higher Order Markov Chains, Release 2