itemid entrydate opeingstock stockin stockout closingstock
DB07 02-10-14 23:05 94000 0 900 93100
DB07 03-10-14 23:05 93100 1000 0 94100
DB07 03-10-14 23:06 94100 0 500 93600
DB07 14-10-14 23:52 97600 0 1500 96100
答案 0 :(得分:0)
试试这个:
select
TABLE1.openingstock,
(TABLE1.openingstock + TABLE2.stockin - TABLE2. stockout) 'closingstock'
from
TABLE1 INNER JOIN TABLE2
ON TABLE1.itemid = TABLE2.itemid
返回2列......
如果这不是您想要的,请添加更多信息,例如示例。