Skip to content

count

relationalai.semantics.std.aggregates
count(*args: AggValue) -> Aggregate

Count the number of values.

  • *args

    (AggValue, default: ()) - Values to count. Can include Distinct wrapper for distinct count.
  • Aggregate - An Aggregate representing the computation of the count. Returns Integer.

Count all employees:

>>> select(aggregates.count(Employee))

Count employees per department:

>>> select(Department, aggregates.count(Employee).per(Department))
RelationalAI Documentation
└──  Build With RelationalAI
    └──  Understand how PyRel works
        ├──  Build a semantic model
        │   └──  Query a model
        │       └──  Aggregate results with count and per
        └──  Use advanced reasoning > Rules-based reasoning
            └──  Aggregate and group data
                └──  Count matches with .count()