关键点group by 分组SELECT distinct 项目号字段, sum(a.数量字段) from 表 as a group by 项目号字段 order by sum(a.数量字段)
这样不就行了吗,没必要用distinct