Order By with COUNT

Posts   
 
    
Jazz
User
Posts: 63
Joined: 12-Aug-2005
# Posted on: 18-Aug-2005 15:39:04   

Hello there,

how to get this with llbl-sorting to work?

SELECT ID_Graph FROM dbo.tblGraphBezier GROUP BY ID_Graph ORDER BY COUNT(ID_Bezier)

ID_Bezier and ID_Graph are both Foreign Keys and I want to get the ID_Graph that has the most referenced ID_Beziers.

Regards, André

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 19-Aug-2005 09:23:25   

You've to add the field you're sorting on to the select list as well, and then add the same field to the SortExpression using new SortClause(field, ...)

Frans Bouma | Lead developer LLBLGen Pro
Jazz
User
Posts: 63
Joined: 12-Aug-2005
# Posted on: 19-Aug-2005 14:47:38   

Hello Otis,

how do i include the COUNT statement?

Regards, André

Jazz
User
Posts: 63
Joined: 12-Aug-2005
# Posted on: 19-Aug-2005 14:49:21   

ah, never mind. I think I found something in the Documentation 'How do I use a group by clause in a dynamic list ?'