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
: