https://www.w3resource.com/sql/aggregate-functions/Max-with-group-by.php
entity myEntity {
key ID: Integer;
key seqNr: Integer;
key createdAt: DateTime;
...
}
@readonly
entity myEntityMaxSeqNr
as select from myEntity {
ID,
count(seqNr) as maxSeqNr: Integer
createdAt,
...
}
group by
ID,
createdAt;
This can also be done using CQL like here.