0

我需要得到满足条件的 bug_idtimediff(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

4

3 回答 3

1

选择 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)) 已执行,(从 bugs.product_id=237 和 bugs.resolution='FIXED' 和 bugs.creation_ts > ='2013-06-14 09:00:00' 和 bugs.creation_ts <= '2013-06-16 08:59:59' 和 bug_status="RESOLVED";

于 2013-06-15T10:41:13.007 回答
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 | 超过| exeededbugids |
+---------+---------+---------+------------------+
| 5 | 6 | 2 | 3743304,3743305 |
+---------+---------+---------+------------------+
一组中的 1 行(0.00 秒)

于 2013-06-15T10:52:56.887 回答
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";
于 2013-06-17T05:14:32.043 回答