You could try and get some inspiration from the:
There also is an example with H2 standalone database and using window functions.