使用sql查询过滤数据以在条形图中显示 [英] filtering data using sql query for show in bar graph

查看:75
本文介绍了使用sql查询过滤数据以在条形图中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是想要做的.我想为X轴过滤工作类型,为y轴过滤工作计数.到X轴,我想获得名称相似的作业类型,以仅使用一次,并在y轴上使用该作业计数. 如果我考虑切割,则将为切割(x轴)- 1400 (第二和第五行的y轴总和).那么如何使用sql查询来获取它呢?我的表名是供应商.

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.

输出如下:

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

推荐答案

您可以在jobType上执行GROUP BY并使用

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

这篇关于使用sql查询过滤数据以在条形图中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆