如何将总额与金额进行比较?
该表看起来像这样:
id, price, amount, transactionid
1, 5, 10, abc
2, 5, 10, abc
3, 20, 40, def
4, 20, 40, def
5, 15, 40, xyz
6, 20, 40, xyz
我想将金额的总和与数量和仅相等的选择比较。
另外,在示例中:15 + 20!= 40
SELECT sum(price), transactionid FROM payment group by transactionid
现在我需要一排中的数量之一的检查,并且仅在不相等的情况下显示。
The table looks like this:
id, price, amount, transactionid
1, 5, 10, abc
2, 5, 10, abc
3, 20, 40, def
4, 20, 40, def
5, 15, 40, xyz
6, 20, 40, xyz
I want to compare the sum of the amounts with the amount and only select that are not equal.
Also in the example: 15 + 20 != 40
SELECT sum(price), transactionid FROM payment group by transactionid
Now I need the check with one of the amounts from a row and show only if is unequal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置
具有
子句中的条件:请参阅。
Set the conditions in the
HAVING
clause:See the demo.