SQL queries

Query lists of records and inspect the typed rows that SQL returns.

type Caption = { speaker: String, words: Number }
let captions: List<Caption> = [
    {speaker="Narrator", words=8},
    {speaker="Guest", words=15},
    {speaker="Host", words=23}
]
let minimum_words = reflect(10)
query<Caption>(
    "SELECT speaker, words FROM captions WHERE words >= {minimum_words} ORDER BY words",
    tables={captions=captions},
)

Change Minimum Words to see which rows match. Use {value} in the SQL string to bind a value, or SqlIdent(name) to quote an identifier. query<Caption> checks that the result columns match Caption. Use Option<T> for nullable results and ORDER BY when the order matters.

Use Charts to plot query results, or DataFrames for column operations.