select 商品.商品卡号, 
       商品.商品名, 
       sum(case 出货数据.取引区分 when '22' then -出货明细.销售金额 
                                 when '23' then -出货明细.销售金额 
                                 else 出货明细.销售金额 end ) 
       as 销售金额
from 商品 
join 出货明细 on 出货明细.商品卡号=商品.商品卡号
join 出货数据 on 出货数据.出货发票=出货明细.出货发票
where 商品.大分类='1' and 商品.中分类='1' and  出货数据.部门卡号='1'
      and year(出货数据.出货日期)=year(getdate())
      and month(出货数据.出货日期)=month(getdate())
group by 商品.商品卡号,商品.商品名
order by 商品.商品卡号