module ActiveRecord::Calculations

def count(column_name = nil)

between databases. In invalid cases, an error from the database is thrown.
Note: not all valid {Relation#select}[rdoc-ref:QueryMethods#select] expressions are valid #count expressions. The specifics differ

# => counts the number of different age values
Person.select(:age).count

If #count is used with {Relation#select}[rdoc-ref:QueryMethods#select], it will count the selected columns:

# ["published", "business"]=>0, ["published", "technology"]=>2}
# => {["draft", "business"]=>10, ["draft", "technology"]=>4,
Article.group(:status, :category).count

of each key would be the #count.
keys are an array containing the individual values of each column and the value
If #count is used with {Relation#group}[rdoc-ref:QueryMethods#group] for multiple columns, it returns a Hash whose

# => { 'Rome' => 5, 'Paris' => 3 }
Person.group(:city).count

and the values are the respective amounts:
it returns a Hash whose keys represent the aggregated column,
If #count is used with {Relation#group}[rdoc-ref:QueryMethods#group],

# => counts the number of different age values
Person.distinct.count(:age)

# => performs a COUNT(*) (:all is an alias for '*')
Person.count(:all)

# => returns the total count of all people whose age is present in database
Person.count(:age)

# => the total count of all people
Person.count

Count the records.
def count(column_name = nil)
  if block_given?
    unless column_name.nil?
      raise ArgumentError, "Column name argument is not supported when a block is passed."
    end
    super()
  else
    calculate(:count, column_name)
  end
end