Literal expressions in the select list may appear in the GROUP BY clause. For example, the following statement uses an aggregate function and a literal expression in the select list, and does not use a GROUP BY clause:
SELECT COUNT(*), SUBSTRING( CAST( CURRENT_TIME(0) AS CHAR(14) ) FROM 1 FOR 8 ) FROM Sales_Table;
The results of such statements when the table has no rows depends on the type of literal expression.
Literal Expression | Result of Literal Expression in Query Result |
---|---|
Does not contain a column reference Is a non-deterministic function, such as RANDOM |
Value of the literal expression. Functions such as RANDOM are computed in the immediate retrieve step of the request instead of in the aggregation step. Here is an example: SELECT COUNT(*), SUBSTRING(CAST(CURRENT_TIME(0) AS CHAR(14)) FROM 1 FOR 8) FROM Sales_Table; Count(*) Substring(Current Time(0) From 1 For 8) Result: -------- --------------------------------------- 0 09:01:43 |
Contains a column reference Is a UDF |
NULL. Here is an example: SELECT COUNT(*), UDF_CALC(1,2) FROM Sales_Table; Count(*) UDF_CALC(1,2) Result: ----------- ------------- 0 ? |