select ID,sum(unit * quantity) as count,
case min(
case status
when 'Fail' then 1
when 'Pending' then 2
when 'OK' then 3
end
)
when 1 then 'Fail'
when 2 then 'Pending'
when 3 then 'OK'
end as status
from table
group by ID
※ 引述《DRLai (苏打)》之铭言:
: 数据库名称:MariaDB
: 数据库版本:10
: 内容/问题描述:
: 资料大致如下
: ID unit quantity status
: