SELECT clauses
The
SELECT
statement supports the ALL
and DISTINCT
set quantifiers. You cannot use CASE
and WHEN
expressions.- FROMTIP:You can use subqueries for theFROMand for theINpredicate.TheFROMclause is required, other clauses are optional.The clauses must have the following order:FROM,WHERE,GROUP,HAVING,ORDER,LIMIT.
- JOIN
- ASTIP: Aliases for tables and columns support regular and delimited identifiers.
- WHERE
- GROUP BY
- ORDER BY
- Set function, including:COUNT,MAX,MIN,AVG, andSUM.
- HAVING
- LIMITTIP:Use theLIMIT OFFSETvariant to limit the number of records. The offset is optional and its default value is0.For example,SELECT * FROM Table1 LIMIT 1000 OFFSET 10returns 1000 records starting from the record number 10.
Examples
The following are examples of
SELECT
clauses:
SELECT *, FROM Table1
SELECT *, Timestamp AS T FROM Table1
SELECT Column1 FROM Table1
SELECT *, 10 FROM Table1
SELECT 10, * FROM Table1
SELECT *, 'text value' FROM Table1
SELECT COUNT(*) FROM Table1
SELECT DISTINCT Column1 FROM Table1
SELECT Variable1 AS Label, AVG(Variable1) AS Value FROM Datalogger1 AS A UNION JOIN (SELECT Variable2 AS Label, AVG(Variable2) AS Value FROM Datalogger1 ORDER BY Label ASC) AS B ON A.Label = B.Label AND A.Value = B.Value
Provide Feedback