liveBook · Manning

Select statement

As explained in DuckDB in Action

A SELECT statement is an SQL statement that retrieves rows and expressions from one or more data sources.

A SELECT statement retrieves rows or expressions from one or more data sources. It can filter, deduplicate, transform, and feed results directly into another SQL operation, making it a practical link between files, tables, and data pipelines. section 3.4.1 section 3.4

Common workflow uses include:

  • Filter stored readings with WHERE and expressions such as date_trunc. section 3.4.1
  • Select distinct columns from a CSV relation before inserting them into a table. section 3.4.1
  • Transform source values with CASE while loading remote CSV data. section 3.4.1

Inspect one day of readings

SELECT * FROM readings WHERE date_trunc('day', read_on) = '2019-08-26' AND power <> 0; This query returns the nonzero readings for one day, including timestamps and power values. section 3.4.1

SELECT *
FROM (
    SELECT 'https://' || years.range || '.csv' AS v
    FROM range(2019,2021) years
) urls, read_csv_auto(urls.v);

Builds a SELECT-derived URL relation and passes it to read_csv_auto, demonstrating how queries can connect generated values with file ingestion. section 3.4.1

How DuckDB in Action covers it

How deep it goes
Explains practical composition with WHERE, DISTINCT, CASE, and external CSV sources while deferring detailed SELECT anatomy.
Examples
Demonstrates daily readings, distinct systems, remote CSV ingestion, generated URLs, and SELECT-fed INSERT statements.
What it assumes
Assumes familiarity with DuckDB data ingestion, CSV files, column detection, tables, and SQL data types.
What you can do after
Apply it via DuckDB to inspect readings, clean source values, deduplicate rows, and route query results into tables.
How it connects
Connects SELECT with INSERT, DELETE, UPDATE, WHERE clauses, CSV files, data types, common table expressions, and window functions.

Also explained in

Compare how 9 books explain select statement →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of DuckDB in Action. The section links point to the parts of the book it draws on.