Mysql - 使用

时间:2016-09-23 20:45:13

标签: sql subquery

人们请帮助我,

我在同一张表中选择了这些选项只有不同的选项是" b.status = x":

SELECT c.name as technician,COUNT(a.tickets_id) AS total
FROM glpi_tickets_users a 
JOIN glpi_tickets b ON a.tickets_id = b.id 
JOIN glpi_users c ON a.users_id = c.id 
WHERE a.type=2 AND b.status=2 
GROUP BY a.users_id 
ORDER by total DESC;

SELECT c.name as technician,COUNT(a.tickets_id) AS total 
FROM glpi_tickets_users a 
JOIN glpi_tickets b ON a.tickets_id = b.id 
JOIN glpi_users c ON a.users_id = c.id 
WHERE a.type=2 AND b.status=5 
GROUP BY a.users_id 
ORDER by total DESC

SELECT c.name as technician,COUNT(a.tickets_id) AS total 
FROM glpi_tickets_users a 
JOIN glpi_tickets b ON a.tickets_id = b.id 
JOIN glpi_users c ON a.users_id = c.id 
WHERE a.type=2 AND b.status=6 
GROUP BY a.users_id 
ORDER by total DESC;

所以我想总结技术人员分组的技术人员的总票数,并按总计划分类。

obs:每个选择返回不同的技术人员组

我该怎么做? tks非常

0 个答案:

没有答案