Mysql COUNT PROBLEM。 [英] Mysql COUNT PROBLEM .

查看:72
本文介绍了Mysql COUNT PROBLEM。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ stridnex =选择a.department,COUNT(DISTINCT b.issue_id)为OPEN,COUNT(DISTINCT a.issue_id)为关闭来自ims_job a,ims_job b WHERE a.status ='0'AND b.visible_< ;>'0'和a.visible_<>'0'GROUP BY a.department;



输出



[{department:,OPEN:187,CLOSE:7},{department:Admin,OPEN:187, 关闭:13},{部门:BU操作,打开:187,关闭:1},{部门:业务开发,打开: 187,CLOSE:8},{department:Credit and Collection,OPEN:187,CLOSE:5},{department:Finance, 打开:187,关闭:1},{部门:人力资源,打开:187,关闭:23},{部门: ICT-MIS,OPEN:187,CLOSE:6},{department:Medical Affairs,OPEN:187,CLOSE:2},{ 部门: NurtureMed, OPEN: 187, CLOSE: 1},{ 部门: 操作, OPEN: 187, CLOSE: 7} ,{department:质量管理,OPEN:187,CLOSE:8},{department:Sales,OPEN:187,关闭:4},{部门:贸易营销,开放:187,关闭:1}]



我尝试了什么:



我在OPEN列中遇到问题,而我得到了关闭列的正确输出。你能帮我这个吗?我正在使用mysql。并将使用我的json作为moris图表。

$stridnex = "SELECT a.department, COUNT(DISTINCT b.issue_id) as OPEN , COUNT(DISTINCT a.issue_id) as CLOSE FROM ims_job a , ims_job b WHERE a.status = '0' AND b.visible_ <> '0' AND a.visible_ <> '0' GROUP BY a.department";

output

[{"department":"","OPEN":"187","CLOSE":"7"},{"department":"Admin","OPEN":"187","CLOSE":"13"},{"department":"BU Operations","OPEN":"187","CLOSE":"1"},{"department":"Business Development","OPEN":"187","CLOSE":"8"},{"department":"Credit and Collection","OPEN":"187","CLOSE":"5"},{"department":"Finance","OPEN":"187","CLOSE":"1"},{"department":"Human Resource","OPEN":"187","CLOSE":"23"},{"department":"ICT-MIS","OPEN":"187","CLOSE":"6"},{"department":"Medical Affairs","OPEN":"187","CLOSE":"2"},{"department":"NurtureMed","OPEN":"187","CLOSE":"1"},{"department":"Operations","OPEN":"187","CLOSE":"7"},{"department":"Quality Management","OPEN":"187","CLOSE":"8"},{"department":"Sales","OPEN":"187","CLOSE":"4"},{"department":"Trade Marketing","OPEN":"187","CLOSE":"1"}]

What I have tried:

I got a problem in OPEN column, while i got the correct output for close column. can you help me with this? Im using mysql. and will use my json for moris chart.

推荐答案

您的连接不包括两个ims_job表(a和b)之间的任何连接。它可能会起作用和a.department = b.department。



Brent Hoskisson
Your join doesn't include any connection between the two ims_job tables (a and b). It might work to put "and a.department = b.department".

Brent Hoskisson


这篇关于Mysql COUNT PROBLEM。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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