Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

HLL_CARDINALITY function

Focus mode
HLL_CARDINALITY function - Amazon Redshift

The HLL_CARDINALITY function returns the cardinality of the input HLLSKETCH data type.

Syntax

HLL_CARDINALITY (hllsketch_expression)

Argument

hllsketch_expression

Any valid expression that evaluates to an HLLSKETCH type, such as a column name. The input value is the HLLSKETCH data type.

Return type

The HLL_CARDINALITY function returns a BIGINT or INT8 value.

Examples

The following example returns the cardinality of column sketch in table hll_table.

CREATE TABLE a_table(an_int INT, b_int INT); INSERT INTO a_table VALUES (1,1), (2,1), (3,1), (4,1), (1,2), (2,2), (3,2), (4,2), (5,2), (6,2); CREATE TABLE hll_table (sketch HLLSKETCH); INSERT INTO hll_table select hll_create_sketch(an_int) from a_table group by b_int; SELECT hll_cardinality(sketch) AS cardinality FROM hll_table; cardinality ------------- 6 4 (2 rows)

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.