class Jennifer::QueryBuilder::SumFunction

Overview

Returns the sum of given field values.

Jennifer::Query["users"].select { [_gender, sum(_age).alias("human_age")] }.group(:gender)

Defined in:

jennifer/query_builder/function.cr

Instance Method Summary

Instance methods inherited from class Jennifer::QueryBuilder::Function

alias_tables(aliases) alias_tables, change_table(old_name, new_name) change_table, clone clone, definition(sql_generator)
definition
definition
, filterable? filterable?, operand_sql(operand : SQLNode, generator)
operand_sql(_operand, generator)
operand_sql
, operands : Array(Array(Array(Char) | Array(Float32) | Array(Float64) | Array(Int16) | Array(Int32) | Array(Int64) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | Time::Span | UInt32 | UUID | Nil) | Array(Char) | Array(Float32) | Array(Float64) | Array(Int16) | Array(Int32) | Array(Int64) | Array(String) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | Jennifer::QueryBuilder::SQLNode | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | Time::Span | UInt32 | UUID | Nil) operands, operands_to_sql(generator) operands_to_sql, set_relation(table, name) set_relation, sql_args : Array(DBAny) sql_args

Constructor methods inherited from class Jennifer::QueryBuilder::Function

new(*args) new

Instance methods inherited from class Jennifer::QueryBuilder::Criteria

!=(value : Symbol)
!=(value : Rightable)
!=
, &(other : LogicOperator::Operandable) &, *(value : Rightable) *, +(value : Rightable) +, -(value : Rightable) -, /(value : Rightable) /, <(value : Rightable) <, <=(value : Rightable) <=, ==(value : Symbol)
==(value : Rightable)
==
, =~(value : String) =~, >(value : Rightable) >, >=(value : Rightable) >=, [](key) [], alias(name : String?)
alias : String?
alias
, alias_tables(aliases : Hash(String, String)) alias_tables, as_sql(generator) : String as_sql, asc asc, between(left : Rightable, right : Rightable) between, change_table(old_name : String, new_name : String) change_table, clone clone, contain(value : Rightable) contain, contained(value : Rightable) contained, definition(sql_generator)
definition
definition
, desc desc, eql?(other : Criteria) eql?, equal(value : Rightable) equal, field : String field, filterable? filterable?, hash(hasher) hash, identifier(sql_generator)
identifier : String
identifier
, ilike(value : Rightable) ilike, in(arr : Array)
in(arr : SQLNode)
in
, is(value : Symbol | Bool | Nil) is, like(value : Rightable) like, not(value : Symbol | Bool | Nil)
not
not
, not_equal(value) not_equal, not_like(value : Rightable) not_like, not_regexp(value : Rightable) not_regexp, order(direction : String | Symbol) order, overlap(value : Rightable) overlap, path(elements : String) path, regexp(value : Rightable) regexp, relation : String? relation, set_relation(table : String, name : String) set_relation, sql_args : Array(DBAny) sql_args, table : String table, take(key : String | Number) take, to_s(io : IO) to_s, xor(other : LogicOperator::Operandable) xor, |(other : LogicOperator::Operandable) |

Constructor methods inherited from class Jennifer::QueryBuilder::Criteria

new(field : String, table : String, relation = nil) new

Instance methods inherited from class Jennifer::QueryBuilder::SQLNode

alias_tables(aliases) alias_tables, as_sql as_sql, change_table(old_name, new_name) change_table, eql?(other) eql?, set_relation(table, name) set_relation, to_condition to_condition

Instance methods inherited from module Jennifer::QueryBuilder::Statement

as_sql(sql_generator) as_sql, filterable? filterable?, sql_args : Array(DBAny) sql_args

Instance Method Detail

def as_sql(generator) #
Description copied from module Jennifer::QueryBuilder::Statement

Converts node to SQL using sql_generator SQLGenerator.


[View source]
def clone #

Returns a copy of self with all instance variables cloned.