Method: Sequel::Dataset#max

Defined in:
lib/sequel/dataset/actions.rb

#max(arg = (no_arg = true), &block) ⇒ Object

Returns the maximum value for the given column/expression. Uses a virtual row block if no argument is given.

DB[:table].max(:id) # SELECT max(id) FROM table LIMIT 1
# => 10
DB[:table].max{function(column)} # SELECT max(function(column)) FROM table LIMIT 1
# => 7


515
516
517
518
# File 'lib/sequel/dataset/actions.rb', line 515

def max(arg=(no_arg = true), &block)
  arg = Sequel.virtual_row(&block) if no_arg
  _aggregate(:max, arg)
end