我有两张桌子。
可以使用code_one
表连接两个表。
如何使用“按code_two分组的价格总和”?
我试过了:
Select sum(price) from table1 Group By (select a.code_two from table2 a, table1 b where a.code_one = b.code_one)
答案 0 :(得分:1)
select code_two, SUM(price)
from table1 t1 INNER JOIN table2 t2 ON t1.code_one = t2.code_one
group by code_two
答案 1 :(得分:0)
select sum(price) 'Price' from firsttable inner join secondtable on firsttable.code_one = secondtable.code_one
group by secondtable.code_two