Sort Clause on an Aggregate (Field not in select list)

Posts   
 
    
Steve_b
User
Posts: 3
Joined: 17-Apr-2007
# Posted on: 18-Apr-2007 19:59:43   

Hi there,

I'm using LLBLGen Pro 1.0.2005 with adapter scenario. how can I sort to count(myField)?

My select statement in simplified form (there are some joins, but I got that all working)

select a, b, c from myTable group by a,b,c order by count(a) desc

I guess it would be simpler if i rewrote it to this, but i want to know if its possible to do it withouth adding count(a) to the select list. select a, b, c, count(a) as d from myTable group by a,b,c order by d desc

So the question is: How to order by an aggregate field, where the aggregate of this field is not in the select list.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Apr-2007 04:40:05   

So the question is: How to order by an aggregate field, where the aggregate of this field is not in the select list.

No as I've search and tested.

I guess it would be simpler if i rewrote it to this, but i want to know if its possible to do it withouth adding count(a) to the select list. select a, b, c, count(a) as d from myTable group by a,b,c order by d desc

Yes, it would be simpler. Is there a problem in using this approach?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39922
Joined: 17-Aug-2003
# Posted on: 19-Apr-2007 10:39:40   

In 1.0.2005.1, that's not possible as it doesn't support expressions/aggregates in sortexpressions.

Frans Bouma | Lead developer LLBLGen Pro