6

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?

F. Böller
  • 4,194
  • 2
  • 20
  • 32

1 Answers1

6

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.

sap1ens
  • 2,877
  • 1
  • 27
  • 30