SQL (Structured Query Language)

SQL is the standard language for defining, querying and changing data held in relational databases, where data sits in tables of rows and columns. It is standardised as ISO/IEC 9075. Analysts use it to select, filter, join and aggregate tables.

What it is

SQL (Structured Query Language) is the standard language for asking questions of data stored in relational databases and for defining and changing that data. A relational database holds data in tables made of rows and columns, and links tables through shared columns. The ISO/IEC 9075 series defines the language in parts; one part sets the framework, another the core data structures and operations, and another the way applications call SQL from other programming languages.

SQL statements fall into three groups:

A query is built from clauses:

Database systems add their own extensions, so the core statements are portable and the advanced ones need adapting.

Why it matters

Most financial data sits in databases: trades, positions, ledgers, client records. SQL is how an analyst reaches it without waiting for someone to build a report. A query is also a record of how a number was produced, so another person can read it, rerun it and check it.

Wrong SQL gives a plausible but wrong figure. A join on the wrong column, or a filter in the wrong place, changes the total without any error message.

Worked example

Illustrative numbers. A table trades holds five rows (trade_id, desk, notional): 1, A, 100; 2, A, 250; 3, B, 80; 4, B, 120; 5, B, 50. A second table desks gives each desk its region: A is North, B is South.

SELECT d.region, SUM(t.notional) AS total
FROM trades t
JOIN desks d ON d.desk = t.desk
WHERE t.notional >= 100
GROUP BY d.region

Step by step: the join attaches a region to each trade; the filter keeps trades 1, 2 and 4; the grouping adds them by region.

Result: North = 100 + 250 = 350; South = 120.

Trades 3 and 5 are dropped by the filter. If the filter is moved after the grouping, or removed, South becomes 80 + 120 + 50 = 250, which answers a different question.

How to read it

A result is read against the question and against a check: the row count before and after each join, and the total compared with a source report. A join that multiplies rows, because the linking column is not unique, inflates sums.

Assumptions

Who uses it

Common confusions

8Roles that need it

9Skills behind it

Sources behind this page (2) · Updated 4 Nov 2026

Concept