我需要获取满足条件timediff(delta_ts,creation_ts) > "00:01:00"
我用这个
创建了查询GROUP_CONCAT(
DISTINCT
bug_id
from bugs
where
timediff(delta_ts,creation_ts) > "00:01:00"
SEPARATOR ' '
)
请帮忙,因为我在此查询中收到错误:
select sum(IF(priority="P3",1,0)) P3count,
SUM(IF(priority="P2",1,0)) P2count,
sum(IF(timediff(delta_ts,creation_ts) > "00:01:00",1,0)) exeeded,
GROUP_CONCAT(DISTINCT bug_id from bugs where priority="P2")
from bugs
where bugs.product_id=237
and bugs.resolution='FIXED'
and bugs.creation_ts >='2013-06-14 09:00:00'
and bugs.creation_ts <= '2013-06-16 08:59:59'
and bug_status="RESOLVED";
投掷错误:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to usenear 'from bugs where priority="P2") from bugs where bugs.product_id=237 and bugs.res' at line 1
答案 0 :(得分:1)
选择总和(IF(优先级=&#34; P3&#34;,1,0))P3count,SUM(IF(优先级=&#34; P2&#34;,1,0))P2count,sum( IF(timediff(delta_ts,creation_ts)&gt;&#34; 00:01:00&#34;,1,0))exeeded,(从优先级为&#34; P2&#34;的错误中选择GROUP_CONCAT(DISTINCT bug_id) )作为bugs.product_id = 237和bugs.resolution =&#39; FIXED&#39;和bugs.creation_ts&gt; =&#39; 2013-06-14 09:00:00&#39;和bugs.creation_ts&lt; =&#39; 2013-06-16 08:59:59&#39;和bug_status =&#34;已解决&#34;;
答案 1 :(得分:1)
我得到了答案,但查询非常复杂。我在嵌套查询的内部和外部编写相同的条件。
select
sum(IF(priority="P3",1,0)) P3count,
SUM(IF(priority="P2",1,0)) P2count,
sum(IF(timediff(delta_ts,creation_ts) > "00:01:00",1,0)) exeeded,
(select GROUP_CONCAT(DISTINCT bug_id) from bugs
where timediff(delta_ts,creation_ts) > "00:01:00"
and bugs.product_id=237
and bugs.resolution='FIXED'
and bugs.creation_ts >='2013-06-14 09:00:00'
and bugs.creation_ts <= '2013-06-16 08:59:59'
and bug_status="RESOLVED") as exeededbugids
from bugs
where bugs.product_id=237
and bugs.resolution='FIXED'
and bugs.creation_ts >='2013-06-14 09:00:00'
and bugs.creation_ts <= '2013-06-16 08:59:59'
and bug_status="RESOLVED";
+---------+---------+---------+-----------------+ | P3count | P2count | exeeded | exeededbugids | +---------+---------+---------+-----------------+ | 5 | 6 | 2 | 3743304,3743305 | +---------+---------+---------+-----------------+ 1 row in set (0.00 sec)
答案 2 :(得分:0)
select
sum(IF(priority="P3",1,0)) P3count,
SUM(IF(priority="P2",1,0)) P2count,
sum(IF(timediff(delta_ts,creation_ts) > "00:01:00",1,0)) exeeded,
GROUP_CONCAT(DISTINCT bug_id) as exeededbugids
from bugs
where timediff(delta_ts,creation_ts) > "00:01:00"
and bugs.product_id=237
and bugs.resolution='FIXED'
and bugs.creation_ts >='2013-06-14 09:00:00'
and bugs.creation_ts <= '2013-06-16 08:59:59'
and bug_status="RESOLVED";