thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Foundational

COUNT Function

An aggregate that counts rows: COUNT(*) counts every row, COUNT(col) counts non-null values, COUNT(DISTINCT col) counts unique non-null values.

Definition

The three forms give different answers when NULLs or duplicates exist, which makes COUNT a reliable exam topic. APPROX_COUNT_DISTINCT (HyperLogLog) in Snowflake, BigQuery and Databricks trades a small error for speed.

Example

SELECT COUNT(*), COUNT(Email), COUNT(DISTINCT Email) FROM Customers;

Exam tip

COUNT(*) ≥ COUNT(col) ≥ COUNT(DISTINCT col) always holds.

Related terms