Hi Guys,
I have a query here:
select p.tag_id, sum(p.stats)
from main.tags t inner join main.posts p on t.id = p.tag_id
group by p.tag_id
order by sum(p.stats) desc
So what I basically want to achieve is get tags using order by clause like one above.
Now I produced code like this:
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.Relations.Add(TagEntity.Relations.PostEntityUsingTagId, JoinHint.Inner);
IGroupByCollection groupBy = new GroupByCollection(PostFields.TagId);
ISortExpression sorter = new SortExpression(?????);
and I'm stuck here in SortExpression.
My question is : How can I create the sort expression which will use an aggregate function like Sum(p.stats) instead of field?
Appreciate any help,
thanks,
F