4.8/5
Home

Integrations

Plug Count neatly into your existing data infrastructure

For data teams

Collaborative, AI-driven data exploration and modelling

For product & growth

Faster access to the answers which matter

For leaders

Turning data into an engine of improvement

Pricing

Latest post

Meet the new Count Agent

Meet the new Count Agent

Docs

Guides, references, and API docs

Blog

Opinions, analysis, and the occasional uncomfortable truth about data.

Webinars

Join our experts for deep dives into data analytics and business intelligence

Gallery

Browse ready-to-use canvas templates and try them instantly

Sign in

Where to begin?

Start for free

Spin up a canvas and explore your data — a couple of clicks, no card.

Book a demo

See it live. Bring your questions — we’ll bring the answers.

Still not sure?

Send us a note — we’ll point you the right way.

Data to decisions, faster.

Compare

  • Count vs BI
  • Count vs Notebooks
  • Count vs Chatbots
  • Count vs Hex
  • Count vs Looker
  • Count vs Tableau
  • Count vs Thoughtspot

Learn

  • Blog
  • Webinars
  • SQL tutorials

Legal & security

  • Privacy Policy
  • Terms of Use
  • Cookies Policy
  • Trust Center
  • Security

Social

  • LinkedIn →
  • YouTube →
  • X →

Start with the hard question.

Ask Count anything — we’ll take you straight into a canvas.

Opens sign-up with your prompt ready for Count.

© 2026 Count Technologies Ltd. All rights reserved.

Careers →Book a Demo →
count

SQL Resources

Count is the best SQL IDE, wrapped up in the best data analysis tool, all inside the best BI platform.

ARRAY_AGG
Arrays Explained
Arrays Explained
CASE
CAST
COALESCE
CONCAT
COUNT [DISTINCT]
DefinitionPractical InfoRelated Pages
CURRENT_DATE
CURRENT_DATETIME
CURRENT_TIMESTAMP
DATETIME_DIFF
DATETIME_TRUNC
DATE_DIFF
DATE_TRUNC
Data Types
Dates and Times
EXTRACT
IF
MEDIAN
SUBSTR
String Functions Explained
TIMESTAMP_DIFF
TIMESTAMP_TRUNC
TIME_DIFF
TIME_TRUNC
UNNEST
Window Functions Explained
SQL Resources/BigQuery Standard SQL/COUNT [DISTINCT]

COUNT [DISTINCT]

COUNT DISTINCT function. Definition, syntax, examples and common errors using BigQuery Standard SQL. The COUNT function returns the number of rows in a SQL expression.

Definition

The COUNT function returns the number of rows in a SQL expression.

  • COUNT(*) counts the number of rows in the input.
  • COUNT(expression) returns the number of rows in the expression other than NULL.
count_all_rowscount_xcount_all_unique_values_of_x
543

The example above shows three different ways COUNT can be used.

COUNT(*) [OVER (...)]

COUNT([DISTINCT] expression) [OVER (...)]
  • COUNT(*) counts the number of rows in the table x.
  • COUNT(x) counts the number of elements in the table x excluding NULL values.
  • COUNT(DISTINCT x) counts the number of unique elements in the table x, excluding NULL values.

COUNT can also be used as a window function. The below example runs the count function for each value of x.

SELECT
  COUNT(*) AS count_all_rows,
  COUNT(x) AS count_x,
  COUNT(DISTINCT x) AS count_all_unique_values_of_x
FROM
  UNNEST([1, 2, 2, 5, NULL]) AS x
xcount_all_rowscount_xcount_unique_x
null100
1111
2221
2221
5111

Practical Info

  • expression can be any data type, but if DISTINCT is used then the data type needs to be groupable (all types other than ARRAY, STRUCT and GEOGRAPHY).
  • The data type of the output is INT64.

Related Pages

  • Window Functions Explained
SELECT
  x,
  COUNT(*) OVER (PARTITION BY x) AS count_all_rows,
  COUNT(x) OVER (PARTITION BY x) AS count_x,
  COUNT(DISTINCT x) OVER (PARTITION BY x) AS count_unique_x
FROM
  UNNEST([1, 2, 2, 5, NULL]) AS x

Got a CSV?
See it differently in <2 mins

Get started for FREEWatch our CEO do it