Atlas · skill

SQL

SQL expresses queries and transformations over relational data. In AI work, the skill is constructing correct analytical datasets through joins, aggregation, windows and explicit time logic, while understanding nulls, cardinality and execution plans well enough to avoid misleading results or unnecessarily expensive computation.

toolProgramming Languages

What it is

A SQL query describes a desired result, and a database optimizer chooses an execution strategy. Tables carry rows and columns, while relational operations filter, combine and aggregate them. Joins can multiply rows; grouping changes the observation unit; window functions compute across related rows while retaining row-level output. Null participates in three-valued logic rather than behaving like an ordinary value. Dialects differ in syntax and functions. Competence therefore involves reasoning about the data model and query semantics, not merely translating a question into a SELECT statement.

What the work involves

The practitioner establishes the intended grain and keys, checks source freshness and defines filters before joining data. They choose join types from the treatment of unmatched records, validate expected cardinality and handle nulls deliberately. For prediction datasets, time conditions ensure that records were available at the relevant decision point. They inspect plans, partition pruning and large intermediate results. The deliverable is a query and documented output contract with checked counts and aggregates that downstream modeling or reporting can trust.

Illustrative example

An engineer assembles customer-level monthly features from orders and support contacts. Orders and contacts are each aggregated to customer-month before joining, preventing one contact from duplicating every order. A window function calculates prior-month activity with a strictly historical frame. A small fixture includes customers with no orders and missing contact dates, allowing the engineer to verify which rows and totals should survive.

Limits and common mistakes

A query that runs successfully may still use the wrong grain, silently exclude nulls or duplicate measures. Window ordering can be ambiguous when timestamps tie, and temporal filters can leak future information. Performance depends on storage layout, indexes and optimizer behavior as well as syntax. Check keys, unmatched records and hand-calculated fixtures before accepting a large analytical result; an execution plan alone does not establish semantic correctness.

Prerequisites

No prerequisites.

Sources and further reading

Last updated: 2026-10-10