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.

COUNT
Dates
FROM
FROM a tableFROM a subqueryIncluding a JOIN clause
JOIN
Strings
WHERE
SQL Resources/SQL/FROM

FROM

The FROM clause is one of the fundamental building blocks of a SQL SELECT statement. In this article we'll explain how it works.

The FROM clause is one of the fundamental building blocks of a SQL SELECT statement. In this article we'll explain how it works.

The FROM clause is formed of the reserved 'from' keyword followed by either:

-- Generic SQL SELECT statement
select
  -- (some columns)
from
  -- (some tables)
where
  -- (A 'predicate' expression to be used as a filter)
group by
  -- (some columns)
  • A table name (most common)
  • A subquery
  • A JOIN clause (read more about the JOIN clause)

The sources defined in the FROM clause determine the set of rows that the SELECT statement can operate on, and so is the first part of the query to be executed.

In this article, we'll look at some examples of different FROM clauses.

with my_table as (select * from unnest([
  struct('a' as strings, 1 as numbers),
  struct('b' as strings, 2 as numbers),
  struct('c' as strings, 3 as numbers)
])) 
-- ^ The SELECT above is just defining some data to use
select
  *
from
  my_table
ℹ️

In this article the code snippets are written in the Google BigQuery Standard SQL syntax.

FROM a table

The simplest FROM clause just lists a single table name - then the entire SELECT statement is operating on a single table.‍

stringsnumbers
a1
b2
c3

FROM a subquery

Instead of referring to a table by name, we can also refer to it as the result of a SELECT statement (since SELECT statements return tables). For example, we can rewrite the query above as

select
  *
from
  (select * from unnest([
    struct('a' as strings, 1 as numbers),
    struct('b' as strings, 2 as numbers),
    struct('c' as strings, 3 as numbers)
  ]))
stringsnumbers
a1
b2
c3

or indeed as

stringsnumbers
a1
b2
c3

These subqueries can be as complex as you'd like, though for the sake of readability you should try to avoid putting too much logic into a subquery. In a Count notebook we encourage splitting complex queries into separate cells for this reason.

Including a JOIN clause

When you want to select rows from multiple tables, you'll need to tell the database how to merge the tables together (read more here). These instructions take the form of one or more JOIN clauses after the initial FROM clause. For example:

with my_table as (select * from unnest([
  struct('a' as strings, 1 as numbers),
  struct('b' as strings, 2 as numbers),
  struct('c' as strings, 3 as numbers)
])) 
select
  *
from
  (
    select * from (
      select * from (
        select * from my_table
      )
    )
  )
numbersnumbers_2
14
25
36

In the query above, our SELECT statement says that:

with table_1 as (select * from unnest([
  struct('a' as strings, 1 as numbers),
  struct('b' as strings, 2 as numbers),
  struct('c' as strings, 3 as numbers)
])),
table_2 as (select * from unnest([
  struct('a' as strings_2, 4 as numbers_2),
  struct('b' as strings_2, 5 as numbers_2),
  struct('c' as strings_2, 6 as numbers_2)
]))
select
  numbers,
  numbers_2
from 
  table_1
  left join table_2 on table_1.strings = table_2.strings_2
  • We want the numbers and numbers_2 columns (the database is smart enough to know which tables those columns come from)‍
  • FROMtable_1 and table_2‍
  • The rows of table_2 should be associated with those from table_1 by comparing the columns strings and strings_2

Got a CSV?
See it differently in <2 mins

Get started for FREEWatch our CEO do it