【发布时间】:2013-01-07 20:51:51
【问题描述】:
有如下表格:
已售商品:
code | size | quantity
abc123 | small | 4
abc123 | medium | 2
xyz987 | small | 3
xyz987 | medium | 1
xyz987 | large | 2
价格表:
code | size | price
abc123 | small | 5
abc123 | medium | 7
abc123 | large | 9
xyz987 | small | 10
xyz987 | medium | 13
xyz987 | large | 15
这将是您获得的最佳(更快的查询)方法
结果:
code | sold_items | cash
abc123 | 6 | 34
xyz987 | 6 | 73
【问题讨论】:
-
+1 用于向我们展示表架构、示例数据和预期结果。很久没有看到这样的问题了:)
-
@bonCodigo:非常感谢! :)
标签: mysql sum multiplication