0

条件を満たす bug_id を取得する必要があります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

4

3 に答える 3

1

select sum(IF(優先度="P3",1,0)) P3count, SUM(IF(優先度="P2",1,0)) P2count, sum(IF(timediff(delta_ts,creation_ts) > "00:01 :00",1,0)) 実行 (優先度が "P2" のバグから GROUP_CONCAT(DISTINCT bug_id) を選択) ='2013-06-14 09:00:00' および bugs.creation_ts <= '2013-06-16 08:59:59' および bug_status="解決済み";

于 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";
+---------+---------+---------+-----------------+
| | P3カウント | P2カウント | 実行された | exeededbugids |
+---------+---------+---------+-----------------+
| | 5 | 6 | 2 | 3743304,3743305 |
+---------+---------+---------+-----------------+
セットで 1 行 (0.00 秒)

于 2013-06-15T10:52:56.887 に答える