2017-01-11 91 views
-1
Name  | count 
Charlie  10 
Charlie  5 
Barney  6 
Disney  7 

我希望找到一個SQL查詢,這將總結總對每個名稱和遞減計數的順序打印的總和SQL - 訂單

+2

'SELECT SUM(計數)FROM MYTABLE GROUP BY名稱ORDER BY SUM(計數)DESC' –

+0

而你嘗試過什麼到目前爲止,你可以使用這個tutorial!? –

+0

@ shA.t:我嘗試了以下。 select mytable,SUM(count)from mytable ORDER BY DESC SUM(count) – pruthvi

回答

0
select sum(count) as total 
from tablename 
group by Name; 
0
SELECT SUM(count) as Count FROM table 
GROUP BY Name 
ORDER BY SUM(count) DESC 
0

使用一個查詢

SELECT Name, SUM(count) 
FROM mytable 
GROUP BY Name 
ORDER BY SUM(count) DESC 
0

您可以使用此查詢:

SELECT Name, SUM(count) 
FROM Table 
GROUP BY Name 
ORDER BY SUM(count) DESC 

一般來說,如果您需要任何幫助