Request one row with maximum value in one column in Slick

It seems to me that this is a simple problem, but I'm still trying to find a good solution. I am using Slick 3.0. I want to query the table row that has the highest value in one column. But I do not want to have only the highest value (this is simple), I want to have the whole line. I tried some things like query first max and then filter with that maximum value, but nothing made up or didn't look suitable. I would expect that there would be a way:

table.maxBy(_.columnName) 

But I did not find such a method. So what is your favorite way to do something like this?

+6
source share
1 answer

The way to do this is to use this query:

 table.sortBy(_.columnName).take(1).result 

Unfortunately, it creates SQL that is not optimized (but correct). Issue is reported and corrected, it will be released in 3.1.0.

+4
source

All Articles