如何总和减去int货币
我有一个带正数和负数和预算表的交易表。如果预算负,负数将增加。
bud_tab
ID | 预算 |
---|---|
1 | 90 |
2 | 80 |
3 | 50 |
4 | 30 |
trans_tab
ID | trans |
---|---|
1 | -50 |
2 | 80 |
3 | -70 |
4 | 60 |
输出
的 | 这样 | 来 |
---|---|---|
获得 | 应该 | 我 |
什么 | | |
| 查询 | 使用 |
30 | 60 | -30 |
I have a transaction table with positive and negative numbers and a budget table. A negative number will increase if being minus with budget.
bud_tab
id | budget |
---|---|
1 | 90 |
2 | 80 |
3 | 50 |
4 | 30 |
trans_tab
id | trans |
---|---|
1 | -50 |
2 | 80 |
3 | -70 |
4 | 60 |
What query should I use to get an output like this:
budget | trans | total |
---|---|---|
90 | -50 | 140 |
80 | 80 | 0 |
50 | -70 | 120 |
30 | 60 | -30 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从输出的外观来看,这似乎是一个基本的数学计算。我想念什么吗?
From the look of output, this seems like a basic math calculations. Am I missing something ?