相关SQL如下:
1、select a1.amount+a2.amout
from a
left join (select sum(amount) amount from a where type='类别1')a1 ON a.id=a1.id
left join (select sum(amount) amount from a where type='类别2')a2 ON a.id=a2.id
2、select sum(case when type in ('类别1','类别2') then amount else 0 end ) amount
from a
请问:以上两张写法哪种执行效率比较高呢,PS:case when 实际应用场景 CASE WHEN 的条件比较多。