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 the
FROMand for theINpredicate.The
FROMclause 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 the
LIMIT 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
