Skip to main content
On this page

Kater SQL Functions Aggregations

KATER__COUNT_TRUE

How many rows have TRUE in the field.

Family: Aggregations

Syntax

KATER__COUNT_TRUE(field)

Arguments

ArgumentDescription
fieldThe field to aggregate.

Returns

A whole number. The field menu writes @format number(0) beside it.

Usage notes

  • FALSE and empty values are not counted.

Example

This Sandbox query reads the sample shop’s orders. The table shows the rows that Kater gave.

SELECT
orders.channel AS "Channel",
KATER__COUNT_TRUE(orders.is_gift) AS "Gift Orders"
FROM kater_dataset.orders AS orders
GROUP BY
orders.channel
ORDER BY
1
ChannelGift Orders
email64
paid62
store72
web58

Compiles to

The call compiles to the same SQL on DuckDB and on Snowflake.

COUNT(CASE WHEN (orders.is_gift) = TRUE THEN 1 END)

See also