countif

countif — aggregate function to return the count of rows that match the query's predicate.

SYNOPSIS

countif(bool predicate)

countif(T column, bool predicate)

DESCRIPTION

The countif() function with one argument returns the number of rows for which the specified predicate argument evaluates to true. When used with two arguments, it returns the number of rows for which the specified column is not null and the predicate evaluates to true.

EXAMPLE

This example shows how to issue a dynamic aggregation query that counts the number of values that meet a certain criterion.

  1. In LiveView Desktop connected to a server running the Hello LiveView sample, select the ItemsSales table from the Tables pane of the LiveView Tables view.

  2. In the Select field, enter:

    Item, countif (Item, lastSoldPrice > 75) as NumBigSales
    
  3. In the Query field, enter the following:

    group by Item
    
  4. Click Open Query.

The query results open in a grid view. The countif aggregate updates when the number of rows returned by the query changes.

SEE ALSO

This LiveView aggregate function is based on the countif aggregate function in the StreamBase expression language.