我需要知道如何总结记录的所有计数。我有表master_tracking(master_vw_tracking_name_grp),其中有像优先级与恒定值,如果5意味着非常高,如果4高和3中等领域。我也有打开日期的open_date字段名称。现在我可以这样计算了。Mysql如何在一条select语句中运行每个计数的总和
V-HIGH
SELECT substr(open_date,1,10) as time, COUNT(*) as rows FROM
`master_vw_tracking_name_grp`
where assigned_to in ('name1','name2','name3') and substr(open_date,1,16)
between '2011-07-25 00:00' and '2011-07-25 23:59' and priority='5'
group by substr(open_date,1,10) order by 1;
+------------+------+
| time | rows |
+------------+------+
| 2011-07-25 | 9 |
+------------+------+
1 row in set (0.00 sec)
HIGH
SELECT substr(open_date,1,10) as time, COUNT(*) as rows
FROM `master_vw_tracking_name_grp`
where assigned_to in ('name1','name2','name3') and substr(open_date,1,16)
between '2011-07-25 00:00' and '2011-07-25 23:59' and priority='4'
group by substr(open_date,1,10) order by 1;
+------------+------+
| time | rows |
+------------+------+
| 2011-07-25 | 20 |
+------------+------+
1 row in set (0.10 sec)
MEDIUM
SELECT substr(open_date,1,10) as time, COUNT(*) as rows
FROM `master_vw_tracking_name_grp`
where assigned_to in ('name1','name2','name3') and substr(open_date,1,16)
between '2011-07-25 00:00' and '2011-07-25 23:59' and priority='3'
group by substr(open_date,1,10) order by 1;
+------------+------+
| time | rows |
+------------+------+
| 2011-07-25 | 20 |
+------------+------+
1 row in set (0.09 sec)
我需要把它放在Pentaho的仪表盘这样的。
Agent: No. Of Open Tickets Total
ServiceDeskGroup Very High 5| High 4 | Medium 3
9 18 19 97
9 20 20 49
我该如何处理一个查询中打开票据的总和。
这是我见过的最错位的问题,你可以请尝试清除它一点。请阅读此处的格式帮助 - http://stackoverflow.com/editing-help – Ben
请更正您的格式以方便阅读。我做了一些,但请完成它。 – Ariel
不知道你在问什么。每个代理商针对每个优先级的门票数量? '通过assigned_to,date(open_date),priority'从master_vw_tracking_name_grp组中选择assigned_to,date(open_date),优先级,count(*)...应该停止使用'substr'来获取日期时间的部分。 –