It seems to me like a simple problem, but I still try to find a good solution. I am using Slick 3.0. I want to query the row of a table, which has the highest value in one column. But I don't want to only have the highest value (this is simple), I want to have the whole row. I tried some things, like query first the max and then filter with this max value, but nothing compiled or looked appropiate. I would expect to be there a method like that:
table.maxBy(_.columnName)
But I didn't found a method like that. So what's the favorite way to do something like that?
The way to do it is to use this query:
table.sortBy(_.columnName).take(1).result
Unfortunately it produces SQL that is not optimized (but correct). Issue is reported and fixed, it'll be released in 3.1.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With