Query

A query is a request to a database for specific data. It states which fields, rows and conditions are wanted, and the database returns a result set. In relational databases, queries are written in SQL.

Also called: queries · database query · data query

What it is

A query is a precise request to a database for the data that answers a question. It names the fields to return, the table or tables to read and the conditions that rows must meet. The database returns a result set, which is a table of the rows and columns requested.

A query has the following parts:

In a relational database, queries are written in SQL. The NIST MOSAIC guide describes the SELECT statement as the command that pulls data from a database, with a WHERE clause to limit the rows returned and ORDER BY to sort them. NIST also shows counting queries, which count the rows that meet stated conditions, optionally by group. SELECT is the SQL operation that reads data. The other basic operations insert, update and delete data.

A query that only reads leaves the stored data unchanged.

Why it matters

A query turns a business question into a repeatable extraction. The same query run on the same data returns the same result, so a figure can be traced and rerun.

A condition that is too narrow drops rows and understates a total. One that is too wide includes rows that should be excluded.

Worked example

Illustrative numbers. A table holds 1,000 invoice rows. The question is the total invoiced to one customer in one quarter.

The query selects the amount column, restricts rows to that customer and to dates in the quarter, and sums the amounts. Suppose 40 rows match and sum to 120,000 euro.

The analyst compares the result with the ledger total for that customer. A difference points to a missing condition or to a row that the filter removed.

Who uses it

Common confusions

6Roles that need it

7Skills behind it

Sources behind this page (3) · Updated 5 Nov 2026

Concept