SELECT statement retrieves data from one or more datasets.
Syntax
NQL requires explicit column lists. Wildcards (
SELECT * and COUNT(*)) are not supported. See Explicit Column Selection for details.Clause order
Clauses must appear in this order:SELECT— columns to returnFROM— data source(s)JOIN— additional data sources with join conditionsWHERE— row-level filters applied before aggregationGROUP BY— grouping for aggregationsHAVING— filters applied after aggregationQUALIFY— filters based on window function resultsORDER BY— result orderingLIMIT— result count restriction
Examples
Basic query:Table references
Dataset references
Reference your datasets using thecompany_data schema with the dataset ID:
Table aliases
Assign aliases to simplify column references:Rosetta Stone table references
Rosetta Stone provides normalized access to data through three scope levels: global, company-scoped, and dataset-scoped. Each scope determines which data sources your query accesses.To access another company’s data through Rosetta Stone, that company must have
shared their data with you via an access rule. Your own company’s data
(
company_data) is always accessible. See Access Rules
for details on data sharing.Global access
Query all normalized data from all datasets shared with you:Company-scoped access
Query normalized data from a specific company’s datasets:Dataset-scoped access
Query normalized data from a specific dataset:Choosing a scope level
| Scope | Syntax | Use when |
|---|---|---|
| Global | narrative.rosetta_stone | You want all available normalized data from all sources |
| Company | company_data._rosetta_stone | You want data from a specific company only |
| Dataset | company_data."123"._rosetta_stone | You need to combine normalized and non-normalized columns from the same dataset |
Access rules
Query through pre-configured access rules using the provider’s company slug:Column references
Fully qualified names
Use fully qualified column names to avoid ambiguity, especially in joins:Column aliases
Assign aliases to rename columns in results:Accessing nested fields
Access struct fields using dot notation:Special columns
Price column
Every dataset includes_price_cpm_usd (price per 1,000 rows). Use it to filter by cost:
Rosetta Stone field access
Access normalized identity data through the._rosetta_stone special field on any dataset:
Access specific identifier types
Query specific identifier types using theunique_id struct:
DELTA tables
TheDELTA function returns only records that have changed since the last query execution. Use it for incremental data processing.
Syntax
Examples
Delta on a dataset:Subqueries
Subquery in WHERE
Subquery in FROM
EXISTS and NOT EXISTS
Common Table Expressions (WITH)
CTEs let you define named subqueries for reuse within a statement.Syntax
Example
QUALIFY clause
TheQUALIFY clause filters results based on window function values. It’s evaluated after window functions, making it useful for deduplication and ranking.
Syntax
Deduplication example
Keep only the most recent record per user:Multiple window conditions
Budget clauses
Budget clauses control spending on data queries. They are required forCREATE MATERIALIZED VIEW statements.

