第1个回答 推荐于2016-06-20
直接晕掉。。。。。兄弟,好好学学sql哈
突然发现你们都不喜欢用别名
用别名sql多简洁啊
SELECT SUM(A.PRICE*B.QTY) as PRICE
FROM STORAGE_IN_PRODUCT_M A ,
SCANLOG_M B
WHERE A.STORAGE_IN_ID = B.STORAGE_IN_ID
AND A.PRODUCT_ID = B.PRODUCT_ID。本回答被提问者采纳
第2个回答 2011-11-23
把price=修改为sum就可以了
SELECT sum (select sum(price*ScanLog_M.qty) from Storage_In_Product_M where storage_in_id=ScanLog_M.storage_in_id and product_id=ScanLog_M.product_id)
FROM ScanLog_M
第3个回答 2011-11-23
SELECT SUM(STORAGE_IN_PRODUCT_M.PRICE*SCANLOG_M.QTY) as PRICE
FROM STORAGE_IN_PRODUCT_M,SCANLOG_M
WHERE STORAGE_IN_PRODUCT_M.STORAGE_IN_ID = SCANLOG_M.STORAGE_IN_ID
AND STORAGE_IN_PRODUCT_M.PRODUCT_ID = SCANLOG_M.PRODUCT_ID
不过你这样合计 是把全表的数据都合计在一起了!~ 应该有一个分组的字段吧?
第4个回答 2011-11-23
sum(),你SQL有问题