Skip to content
OCTAVIIUS DOCSCore & Studio 0.2.83
SQL reference / 0.2.83

Selection, predicates and relational ordering

SQL projection, NULL logic, parameterized predicates and deterministic pagination.

Projection and predicate evaluation

The projection defines returned columns and influences the amount of data to decode. WHERE combines comparisons, IN, BETWEEN, LIKE and Boolean operators. SQL logic distinguishes NULL from ordinary values: IS NULL and IS NOT NULL are the appropriate tests. Predicate expressions applied to columns must be evaluated with their types and requested conversions in mind.

Structure and identifiers

Common form: SELECT [ALL|DISTINCT] [TOP n] expressions FROM sources WHERE predicate GROUP BY expressions HAVING predicate ORDER BY expressions. Optional clauses follow this order. dbo is the implicit schema; qualify objects as [dbo].[Ventes]. Brackets and double quotes delimit identifiers; string literals use single quotes, doubling an embedded apostrophe. N'text' is accepted for Unicode.

Catalog/parser normalization lowercases many names. Use actual columns names rather than assuming output casing. There is no complete SQL Server collation subsystem; do not assume case-insensitive value comparisons.

SQL
SELECT Id, Pays, Montant AS total_ligne
FROM [dbo].[Ventes]
WHERE Montant >= 10 AND Pays = N'France'
ORDER BY Id;

Predicates and NULL

Predicates include comparisons = <> != < <= > >=, AND, OR, NOT, IS NULL/IS NOT NULL, IN/NOT IN, BETWEEN/NOT BETWEEN and LIKE/NOT LIKE. Parenthesize mixed AND/OR. LIKE supports % and _. Comparisons to NULL are not true: Montant = NULL is not IS NULL. NOT IN containing NULL may evaluate to UNKNOWN and unexpectedly exclude rows.

HTTP parameters are named @minimum and sent separately. ODBC binds ? placeholders through the driver. WHERE is not an authorization boundary: permissions apply to objects, not only filtered rows.

SQL
SELECT Id, Montant FROM dbo.Ventes
WHERE Montant IS NULL OR Pays LIKE N'Port%'
ORDER BY Id;

Ordering, TOP and OFFSET/FETCH

Without ORDER BY there is no stable ordering guarantee, especially in parallel. Include a tie-breaker for deterministic paging. TOP is a dialect extension, not a requirement for table exports or aggregates. Adding TOP before COUNT or SUM changes the answer and is not an equivalent optimization.

OFFSET/FETCH changes the SQL result; batch_rows only partitions transport. Separate page queries may observe different snapshots; use one SELECT and consume its cursor for a coherent export.

SQL
SELECT Id, Montant FROM dbo.Ventes
ORDER BY Id OFFSET 1 ROWS FETCH NEXT 2 ROWS ONLY;

SELECT TOP 2 Id, Montant FROM dbo.Ventes ORDER BY Id;

Expressions and explicit conversions

Simple/searched CASE, CAST, CONVERT, COALESCE, NULLIF, ISNULL and IIF are available within their documented scope. Implicit conversions do not reproduce SQL Server; explicitly type dates, amounts and set branches. Conditional subqueries inside CASE/COALESCE/ISNULL are unsupported.

SQL
SELECT Id, CASE WHEN Montant IS NULL THEN N'absent' ELSE N'present' END AS etat,
       COALESCE(Montant, CAST(0 AS DECIMAL(19,4))) AS montant
FROM dbo.Ventes ORDER BY Id;

Key-based pagination and read consistency

Key-based pagination expresses a bound on a stable identifier. It avoids a growing OFFSET but submits a separate SELECT per page. For a single-snapshot export, retain one SELECT and consume its cursor until complete. Bind @last_id and @pays using BIGINT and NVARCHAR types.

SQL
SELECT TOP 8192 Id, ClientId, Pays, Montant, Jour
FROM dbo.Ventes
WHERE Id > @last_id AND Pays = @pays
ORDER BY Id;