select askuaquantity sku账库存bquantity sku库存 from select skusumquantity quantity from SELECT skuquantity from erp_acc_location_stock_detail WHERE warehouse_code = 11 and stock_attri = 1 and create
This SQL query selects the SKU, SKU account inventory quantity, and SKU inventory quantity for a specific warehouse and stock date. The query joins two tables to compare the SKU quantity in the accounting system versus the actual inventory quantity. The result only shows SKUs where the quantity in the accounting system does not match the actual inventory quantity.
Explanation of the SQL query:
- The first SELECT statement selects the SKU and the sum of the quantity from two tables: erp_acc_location_stock_detail and wh_initial_stock. The WHERE clause filters the records by warehouse code, stock attribute, and create date. The UNION ALL operator combines the results of the two tables. The GROUP BY clause groups the records by SKU.
- The second SELECT statement selects the SKU and the sum of the quantity from the erp_acc_sku_stock_cost_daily table. The WHERE clause filters the records by stock date, warehouse code, and stock site code. The GROUP BY clause groups the records by SKU.
- The INNER JOIN clause joins the two SELECT statements on the SKU column.
- The WHERE clause filters the records by SKU where the quantity in the accounting system does not match the actual inventory quantity.
原文地址: https://www.cveoy.top/t/topic/bjnF 著作权归作者所有。请勿转载和采集!