sql >> Base de Datos >  >> RDS >> Oracle

Excluir el valor de un registro en un grupo si hay otro presente

select 
  id, 
  case 
     when count(case mark when 'C' then 1 else null end) = 0 
     then 
        sum(amount)
     else 
        sum(case when mark <> 'A' then amount else 0 end)
  end
from sampletable
group by id