2013-11-05 158 views
1

有沒有辦法按打開任務的數量進行排序?Microsoft Access按聚合排序?

SELECT Tasks.ClientName, Count(*) AS OpenTaskCount 
FROM Tasks 
WHERE (((Tasks.Completed)=False)) 
GROUP BY Tasks.ClientName 
ORDER BY OpenTaskCount DESC; 

當我嘗試這個時,它提示在GUI中的OpenTaskCount。

+0

你試過ORDER BY Count(*)DESC嗎? –

+0

這樣做!現在,如果你會讓你的答案回答:) – user1594322

回答

2

試試這個:

SELECT Tasks.ClientName, Count(*) AS OpenTaskCount 
FROM Tasks 
WHERE (((Tasks.Completed)=False)) 
GROUP BY Tasks.ClientName 
ORDER BY COUNT(*) DESC; 
2

或者:

SELECT Tasks.ClientName, Count(*) AS OpenTaskCount 
FROM Tasks 
WHERE (((Tasks.Completed)=False)) 
GROUP BY Tasks.ClientName 
ORDER BY Count(*) DESC; 

SELECT Tasks.ClientName, Count(*) AS OpenTaskCount 
FROM Tasks 
WHERE (((Tasks.Completed)=False)) 
GROUP BY Tasks.ClientName 
ORDER BY 2 DESC; 

應該工作。