You can create a relationpredicatebucket(rpb).
In you rpb, you add your filter :
rpb.filter.Add(LogFields.Terminal == 'SqlServer')
you will use this function :
FetchTypedList(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket,
int maxNumberOfItemsToReturn, ISortExpression sortClauses, bool allowDuplicates, IGroupByCollection groupByClause)
wich will allow you to add the sort expression and the groupby clause.
For the sort expression use the code that sami give you and for the groupby clause use code like this :
Dim groupByClause As IGroupByCollection = New GroupByCollection()
groupByClause.Add(fields(0))