sum 与 distinct 同时存在 mysql group

一、案例
如表table:
NAME PACKNO UNITPRICE
A      1      2
A      3      4
B      5      6
B      7      8

如何得到如下结果
NAME SUM   
A      14 (算法: 1*2 + 3*4)
B      86 (算法: 5*6 + 7*8) 

二、解答
select name,sum(packno * unitprice) as sum
from table
group by name

如统计班级60分以上男女人数及总分:
select count(*),sum(`score`) as sum_s from `score` where `score`>60 group by sex order by sum_s;
SELECT sum(num) 
FROM  `vcms_find` 
WHERE word LIKE  '%请输入您要搜索的项目关键字%'
GROUP BY word
LIMIT 0 , 30