select A,sum(買) as 買,sum(賣) as 賣
from
(select A,case B when '买' then C else 0 end as 買,
case B when '卖' then C else 0 end as 賣 from [表]) Tblgroup by A
from
(select A,case B when '买' then C else 0 end as 買,
case B when '卖' then C else 0 end as 賣 from [表]) Tblgroup by A
sum(case B when '卖' then C else 0 end) as 賣 from [表] group by A