我在 MySql 中有两个表:
- 主要:
and_fakture 字段:id、organizatorId、...
- 第二: 和_斯塔夫克 字段:id,idFakture,ukupno,... 其中 and_fakture.id=and_stavke.idFakture
ukupno 是数字
我如何从organizatorId求和(ukupno)?
最佳答案
你的问题不是很清楚,但你想要这样的东西吗?:
SELECT organizatorId, SUM(ukupno)
FROM and_fakture
INNER JOIN and_stavke ON and_fakture.id = and_stavke.idFakture
GROUP BY organizatorId
这将为您提供每个organizatorId 的 ukupno 总和
关于MySql - 从主表和第二个表创建总和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26487176/