Method: Sequel::Dataset#select_group

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

#select_group(*columns, &block) ⇒ Object

Set both the select and group clauses with the given columns. Column aliases may be supplied, and will be included in the select clause. This also takes a virtual row block similar to where.

DB[:items].select_group(:a, :b)
# SELECT a, b FROM items GROUP BY a, b

DB[:items].select_group(Sequel[:c].as(:a)){f(c2)}
# SELECT c AS a, f(c2) FROM items GROUP BY c, f(c2)


966
967
968
969
# File 'lib/sequel/dataset/query.rb', line 966

def select_group(*columns, &block)
  virtual_row_columns(columns, block)
  select(*columns).group(*columns.map{|c| unaliased_identifier(c)})
end