[其他解释] /*盘点*/ SELECT '盘点+' affirm_type, order_date affirm_date, order_id, sell_id_fk, pro_no_fk, pro_num_fk, storage_finance num FROM inventory_m m, inventory_s s WHERE order_id = order_id_fk AND states_id_fk = '3' UNION ALL /*调出*/ SELECT '调库-', head_date, order_id, from_id_fk, pro_no_fk, pro_num_fk, (- 1) * num FROM storage_m m, storage_s s WHERE order_id = order_id_fk AND states_id_fk = '21' UNION ALL /*调入*/ SELECT '调库+', head_date, order_id, to_id_fk, pro_no_fk, pro_num_fk, num FROM storage_m m, storage_s s WHERE order_id = order_id_fk AND states_id_fk = '21' UNION ALL /*订单-*/ SELECT '订单-', fill_date, order_id, fill_id_fk, pro_no_fk, pro_num_fk, (- 1) * fill_num
FROM order_m m, order_s s WHERE order_id = order_id_fk AND states_id_fk = '31' UNION ALL /*订单+*/ SELECT '订单+', fill_date, order_id, sell_id_fk, pro_no_fk, pro_num_fk, fill_num FROM order_m m, order_s s WHERE order_id = order_id_fk AND states_id_fk = '31' UNION ALL /*退货-*/ SELECT '退货-', fill_date, order_id, sell_id_fk, pro_no_fk, pro_num_fk, (- 1) * s.fill_num FROM return_m m, return_s s WHERE order_id = order_id_fk AND states_id_fk = '31' UNION ALL /*退货+*/ SELECT '退货+', fill_date, order_id, fill_id_fk, pro_no_fk, pro_num_fk, s.fill_num FROM return_m m, return_s s WHERE order_id = order_id_fk AND states_id_fk = '31' UNION ALL /*销售-*/ SELECT '销售-', order_date, order_id, sell_id_fk, pro_no_fk, pro_num_fk, (- 1) * num FROM sell_order_m m, sell_order_s s WHERE order_id = order_id_fk UNION ALL /*冻结-*/ SELECT '冻结-', sell_date, order_id, fill_id_fk, pro_no_fk, pro_num_fk, sell_num * (- 1) FROM order_m m, order_s s WHERE order_id = order_id_fk AND states_id_fk IN ('0', '11', '21') UNION ALL /*虚拟+*/ SELECT '虚拟+', getdate(), '-', sell_id_fk, pro_no_fk, pro_num_fk, num FROM stock_ex [其他解释] 实际现在我还有一个思路就是建一个和视图一样的实体表,然后同步,不过这样也有个问题,公司网上是实时订购,如果库存更新不及时会出现订购到库存不足的产品 [其他解释]