select case_no, ; sum(paid) as VISA when nType =1 ; sum(paid) as MASTER when nType =2 ; sum(paid) as CASH when nType =3 ; sum(paid) as EPS when nType =4 ; FROM payment INTO CURSOR tmp Group by case_noHow can I conditionally sum up the payment amount?!