如果你不想用实时的库存表,你可以每月结一次select 产品号,sum(库存数) 现有库存数 from (
select 产品号,库存数 from 表
union all
select 产品号,入库数 from 入库表 where 时间=@本月
union all
select 产品号,-出库数 from 出库表 where 时间=@本月
) tem group by 产品号