Method: Sequel::Dataset#sum

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

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

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

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


880
881
882
883
# File 'lib/sequel/dataset/actions.rb', line 880

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