For the following table structure:
id externalId name version
1 10 n1 1
2 65 n2 2
3 10 n3 2
4 77 n4 1
I'm trying to get all the entries (all columns) that has a max version grouped by externalId. The expected result should be:
id externalId name version
2 65 n2 2
3 10 n3 2
4 77 n4 1
For this purpose, I have the following slick query defined:
val resulting = myTableEntries
.groupBy(x => x.externalID)
.map {
case (id, group) =>
(id, group.map(_.version).max)
}
How can I get all the columns out instead of just the id and the version?
Effectively what I need is a Slick version of the following SQL:
select myTable.id, myTable.name, myTable.externalId, myTable.version
from MyTable myTable
where version =
(select max(revision) from MyTable myTable1 where myTable.id=myTable1.id)