Select sum(amount) * from tablo where type in (1,2,3,4) and (type=4 and not number in (2,3))