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
SUBSTR
String Functions Explained
TIMESTAMP_DIFF
TIMESTAMP_TRUNC
TIME_DIFF
TIME_TRUNC
UNNEST
DefinitionPractical InfoCommon QuestionsRelated Pages
Window Functions Explained
SQL Resources/BigQuery Standard SQL/UNNEST

UNNEST

UNNEST function. Definition, syntax, examples and common errors using BigQuery Standard SQL. The UNNEST function takes an ARRAY and returns a table with a row for each element in the ARRAY.

Definition

The UNNEST function takes an ARRAY and returns a table with a row for each element in the ARRAY.

unnest_column
1
2
2
5
null

The optional WITH OFFSET clause provides an additional column containing the position of each element in the array (starting at zero) for each row produced by UNNEST.

unnest_columnoffset
10
21
22
53
null4

Practical Info

  • UNNEST requires an ARRAY as an input but can return a table of any structure.
  • Empty arrays and NULL as an input returns an empty table. An array containing NULL values will produce a row of NULL values.

Common Questions

How can I quickly generate a table of values in BigQuery?

You can use UNNEST to quickly create simple tables from arrays. For example:

UNNEST(ARRAY) [WITH OFFSET]
fruitnumber
apples4
pears6
bananas2

How do I join each element in an array column to its corresponding row?

You can do this with a CROSS JOIN. A cross join will take every individual element of your unnested array and join it back to its parent row. This will create multiple rows for each element of your array but you can then filter it down.

fruitbasketfruit_unnest
bananas,apples,orangesbasket 1bananas
bananas,apples,orangesbasket 1apples
bananas,apples,orangesbasket 1oranges
bananas,orangesbasket 2bananas
bananas,orangesbasket 2oranges
bananas,applesbasket 3bananas
bananas,applesbasket 3apples

Related Pages

SELECT
  *
FROM
  UNNEST([1, 2, 2, 5, NULL]) AS unnest_column
SELECT
  *
FROM
  UNNEST([1, 2, 2, 5, NULL]) AS unnest_column WITH OFFSET AS `offset`
SELECT
  *
FROM
  UNNEST(
       ARRAY<STRUCT<fruit STRING , number INT64>>[
         ('apples', 4), ('pears', 6), ('bananas', 2)
       ]
  )
AS simple_table;
WITH fruit_baskets as 
(
  SELECT
    * 
  FROM
    UNNEST(
      ARRAY<STRUCT<fruit ARRAY<STRING>,basket STRING>>[
        (['bananas', 'apples', 'oranges'], 'basket 1'),
        (['bananas', 'oranges'], 'basket 2'),
        (['bananas', 'apples'], 'basket 3')
      ]
    )
  AS fruit
)

SELECT * 
FROM fruit_baskets 
CROSS JOIN UNNEST(fruit) as fruit_unnest

Got a CSV?
See it differently in <2 mins

Get started for FREEWatch our CEO do it