把matname替换为productname,quantity替换为realnumber
时间: 2024-10-15 17:18:32 浏览: 12
vue项目打包为桌面应用.doc
明白了,如果我们将表格字段`MatName`替换为`ProductName`,并将`Quantity`替换为`RealNumber`,上面的SQL查询将变成:
```sql
SELECT T1.ProductName AS '产品名称',
(T1.RealNumber + T2.RealNumber - T3.RealNumber) AS '当前库存'
FROM tb1_Inventory T1
JOIN (
SELECT ProductName, SUM(RealNumber) AS RealNumber
FROM tb2_Input
WHERE InputDate = (SELECT MAX(InputDate) FROM tb2_Input)
GROUP BY ProductName
) T2 ON T1.ProductName = T2.ProductName
JOIN (
SELECT ProductName, SUM(RealNumber) AS RealNumber
FROM tb5_Operatelog
WHERE LogDate = (SELECT MIN(LogDate) FROM tb5_Operatolog)
GROUP BY ProductName
) T3 ON T1.ProductName = T3.ProductName
WHERE T1.InventoryDate = (SELECT MAX(InventoryDate) FROM tb1_Inventory);
```
现在查询的结果集中显示的是产品的名称以及基于最新盘点日期计算的实际库存数。
阅读全文