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]
CURRENT_DATE
CURRENT_DATETIME
CURRENT_TIMESTAMP
DATETIME_DIFF
DATETIME_TRUNC
DATE_DIFF
DATE_TRUNC
Data Types
Dates and Times
EXTRACT
IF
MEDIAN
DefinitionPractical InfoCommon QuestionsTroubleshooting Common ErrorsRelated Pages
SUBSTR
String Functions Explained
TIMESTAMP_DIFF
TIMESTAMP_TRUNC
TIME_DIFF
TIME_TRUNC
UNNEST
Window Functions Explained
SQL Resources/BigQuery Standard SQL/MEDIAN

MEDIAN

MEDIAN function. Definition, syntax, examples and common errors using BigQuery Standard SQL. There is no MEDIAN function in BigQuery, but it can be calculated using the PERCENTILE_CONT function.

Definition

There is no MEDIAN function in BigQuery, but it can be calculated using the PERCENTILE_CONT function.

Using this function, you can calculate the median with the following:

PERCENTILE_CONT (value_expression, percentile [{RESPECT | IGNORE} NULLS])

By default NULL values are ignored in the calculation but they can be included with the key words RESPECT NULLS.  If you include NULL values then the following behaviour is important to know.

SELECT
  PERCENTILE_CONT(x, 0.5) OVER () AS median
FROM
  UNNEST([1, 2, 4, 5, NULL]) AS x
LIMIT
  1
  • Any interpolation between two NULL values returns NULL.
  • An interpolation between a NULL and a non-NULL value returns the non-NULL value. (NULL is not just simply treated as 0).

In the example below the results are different because we now take the NULL value in the list of numbers into account, shifting the result to 2.

SELECT
  PERCENTILE_CONT(x, 0.5 RESPECT NULLS) OVER () AS median
FROM
  UNNEST([1, 2, 4, 5, NULL]) AS x
LIMIT
  1

Practical Info

  • PERCENTILE_CONT is a window function. You can learn more about window functions here.
  • value_expression must be either NUMERIC, BIGNUMERIC, FLOAT64.
  • percentile must be a literal between 0 and 1.
  • If you set percentile to 0 or 1 you can use percentile_cont to calculate the minimum and maximum values respectively.
  • The function PERCENTILE_DISC has the same arguments as PERCENTILE_CONT but provides a percentile value for a discrete set of values including strings and any data type that can be ordered.

Common Questions

Why is there no MEDIAN function in BigQuery?

There's no official explanation why MEDIAN function isn't supported. BigQuery has a number of approximate aggregate functions which are designed to give approximate results but are much less computationally expensive across big data sets.

Troubleshooting Common Errors

The query could not be executed in the allotted memory. OVER() operator used too much memory

This error occurs when the table you're analysing is too big for BiqQuery to fit in memory. This can happen with big data tables and particularly if the window function has no partition and it is therefore running the calculation across the whole table. Instead you can use the approx_quantiles function to give you an estimated value.

Related Pages

  • Window Functions Explained

Got a CSV?
See it differently in <2 mins

Get started for FREEWatch our CEO do it