Select



SELECT reads documents from one or more schemas.
SELECT [DISTINCT] [TOP n] { * | alias.* | expression [as Name], ... }
[INTO TargetSchema]
FROM Schema [as alias]
[INNER JOIN | OUTER JOIN Schema as alias ON conditions] ...
[WHERE conditions]
[GROUP BY expression, ...]
[ORDER BY expression [ASC | DESC], ...]
[OFFSET n]

Notes on SELECT *

SELECT * returns every field found in the selected documents. Since documents in a schema don't need to have the same fields, SELECT * must examine every selected document to build the list of fields.

Inconsistent schema fields

Fields are not guaranteed to exist in every document. Fields that are selected but missing from a document are returned as NULL. Set WarnMissingFields to be warned about them.


Fields and expressions can be given a name with as. The as keyword is required. Names that contain spaces must be quoted. Expressions without a name are returned as Expression0, Expression1 and so on.

round-pushpin Selects all fields from the Word schema.
SELECT * FROM WordList:Word

round-pushpin Selects specific fields, an expression and a function from the Word schema.
SELECT
    Id,
    Text,
    Id * 10 as Score,
    ToUpper(Text) as 'Upper Case'
FROM
    WordList:Word
WHERE
    LanguageId = 1

round-pushpin Selects all of the fields of one of the joined schemas.
SELECT
    w.*
FROM
    WordList:Word as w
INNER JOIN WordList:Language as l
    ON l.Id = w.LanguageId
WHERE
    l.Name = 'German'




SQL :: Inner Join
Combines documents from two or more schemas based on matching fields.
SQL :: Insert
Insert creates new documents in a schema.
SQL :: IsNull
Returns true (1) if the given value is null, otherwise false (0). This is how to test for missing fields and for the unmatched side of an outer join.
SQL :: Keywords
A breakdown of all of the statements and keywords supported by the query processor.
SQL :: Left Outer Join
Combines documents from two or more schemas, keeping documents that have no match.
SQL :: Logical Connectors
Connects one logical expression to another.
SQL :: Max
Returns the largest numeric value in each group. Use MaxString for text.
SQL :: MaxString
Returns the alphabetically largest value in each group.
SQL :: Mean
Returns the arithmetic mean of the values in each group (the same as Avg).
SQL :: Median
Returns the median (middle) value in each group. For an even number of values it is the average of the two middle values.