Restrictions for GROUP BY Queries
There are additional restrictions on the queries in which clustering is applied. Clustering fields must be real fields of the tables listed in FROM statement. You can't group the fields on the basis of computing expression value.
Besides, there are some restrictions on the elements of the returning fields' list. All elements of this list should have the only value for each record group. It means that returning field can be :
- aggregative function (returns one value for all the records included to the group);
- cluster field which has the same value in all the group records by declaration;
- the expression which include all above mentioned elements.
In practice the cluster field and aggregative function are included to the returning fields of clustering query. If the aggregative function is not indicated, it means that the query can be simply expressed with the help of DISTINCT predicate without using GROUP BY statement. And on the contrary, if you don't include the group field to query results you can't define which group each result record is related to!