You are here: Using General SQL Parser > Select Statement > Group by clause
ContentsIndexHome
PreviousUpNext
Group by clause

Group by clause in select statement was represented by 2 properties: 

  1. GroupbyClauseText,this is the string representation, you can fetch or set group by clause directly by using this property.
 

Text in GroupbyClauseText includes group by keyword, so if you fetch value from GroupbyClauseText, you can see something like this: group by f1,f2, but not value like this: f1,f2. 

If you want to append new field value, then do something like this: 

GroupbyClauseText = GroupbyClauseText + ",f3" 

 

Or set new value of GroupbyClauseText, 

GroupbyClauseText = "group by f3"; 

  1. GroupbyClause, which is type of TLzGroupBy,and represents detailed information about group by clause.
 

You can also modify GroupbyClauseText via modifying GroupbyClause. By using GroupbyClause, you can take full control of every field involved in Group by Clause. 

 

The key property of TLzGroupBy is GroupItems which is type of TLz_list. And items in GroupItems is type of TLzGroupByItem, so you can always cast items in GroupItems to TLzGroupByItem. 

 

The key property of TLzGroupByItem is _ndExpr which can always been cast to TLzCustomExpression, usually, _ndExpr represents field in the group by clause. 

 

Check BuildSelect function in this demo to find out more information: 

http://www.sqlparser.com/dl/samples/buildsql.zip 

Gudu software http://www.sqlparser.com
Send comments about this topic.