The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Ordering grouped results within GROUP BY clause
I'm having a really tough time with the following query:
[SQL] SELECT scst_task.taskid, scst_task.enddate, scst_task.recurring, scst_fb.fbid, COUNT(scst_fbposts.fbid) AS fbqty, scst_fb.userid, scst_fbposts.statusid, scst_status.status, scst_status.alertmember, scst_status.css, scst_status.icon FROM scst_task LEFT JOIN usergroup ON usergroup.scstugteamid = scst_task.teamid LEFT JOIN scst_fb ON scst_fb.taskid = scst_task.taskid AND scst_fb.userid = 1 LEFT JOIN scst_fbposts ON scst_fbposts.fbid = scst_fb.fbid LEFT JOIN scst_status ON scst_status.statusid = scst_fbposts.statusid WHERE FIND_IN_SET(usergroup.usergroupid, '13,16') > 0 AND scst_task.startdate <= 1183991294 AND scst_task.enddate > 1183991294 GROUP BY scst_task.taskid HAVING fbqty < scst_task.recurring ORDER BY scst_team.teamtitle ASC, scst_task.enddate ASC [/SQL] The problem i am having is with regards to the order of the scst_fbposts records grouped by the COUNT clause. Currently it's ordering them by whatever order they are stored within the database, however I need them ordered by scst_fbposts.statusid ASC. I can easily get that accomplished by adding scst_fbposts.statusid to the GROUP BY clause, however problem is that doing so breaks the COUNT clause and records are no longer grouped. Can someone please help me? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|