filtering data using sql query for show in bar gra

2019-07-25 13:08发布

here is what is want to do. i want to filter Job Types for X axis and Job count for the y axis. to x axis i want to get job type with similar name to use only once and for y axis job count of that. if i consider cutting, then it will be cutting(x axis)-1400(y axis-sum of 2nd and 5th row). so how to get this using a sql query? my table name is supplier.

enter image description here

Output will be like:

| jobType | totaljobCount |
|---------|---------------|
| CPI     | 302           |
| Cutting | 1400          |
| Ironing | 800           |

标签: mysql sql
1条回答
地球回转人心会变
2楼-- · 2019-07-25 13:53

You can do a GROUP BY on the jobType and use SUM() function to aggregate the jobCount values.

SELECT 
  jobType, SUM(jobCount) AS total_jobCount
FROM supplier
GROUP BY jobType
查看更多
登录 后发表回答