Open this example in the interactive library
Source code
WITH events(k,id) AS (VALUES('a',1),('a',2),('b',3)) SELECT k,max(id) AS latest FROM events GROUP BY k;
Sample output
[
{
"k": "a",
"latest": 2
},
{
"k": "b",
"latest": 3
}
]