補充 : 可以用DENSE_RANK()做排行
SELECT DENSE_RANK() OVER(ORDER BY SUM([總價]) DESC) AS NO, [Order] AS Order, SUM([總價]) AS Total_Price
FROM [Table_Name]
group by [Order]
其他還有row_number()、rank()等函式能用
select Order as order_id, SUM('總價') as amount from table_name group by order_id
MSSQL
select [Order],SUM([總價]) Total
from Ordertable
group by [Order]
使用GROUP BY語句與SUM函數
DEMO
select order_num , SUM(total_price)
from sales
group by order_num;