mysql查询表列总和_MySQL查询以查找具有相同列值的字段总和

bd96500e110b49cbb3cd949968f18be7.png

I have a table like this

id | invent_id | order

1 | 95948214 | 70

2 | 46018572 | 30

3 | 46018572 | 20

4 | 46018572 | 50

5 | 36025764 | 60

6 | 36025764 | 70

7 | 95948214 | 80

8 | 95948214 | 90

I want get the sum of order qty with same invent id

That is the want the result like this

| invent_id | order

| 95948214 | 240

| 46018572 | 100

| 36025764 | 130

how can we write the mysql query

解决方案

Make use of Aggregate function SUM and grouped them according to invent_id.

SELECT invent_id, SUM(`order`) `Order`

FROM tableName

GROUP BY invent_ID

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值