在[My]SQL Query Syntax which requires foreach processing我有一个独立的问题,所以我在新帖子中提问。
SQL确实找到了信息,但我想用id = bug_id打印bug_activity行的数量?
每个bug都有一个带bug_id的bug_activity表 我不确定我是否可以打印SELECT和WHERE审核的预先审核的计数..
SELECT
bug_id,
COUNT(*) as ActivityRecords, -- Want this to be the number of bugs_activity records with the id bug_id
SUM(CASE WHEN fielddefs.name ='bug_status' AND (bugs_activity.added = 'IN BACKLOG' OR bugs_activity.added = 'ASSIGNED') THEN 1 ELSE 0 END) as OpenCount
FROM bugs_activity, fielddefs
WHERE bug_when BETWEEN '2016-03-01' AND '2016-03-31'
GROUP BY bug_id
HAVING OpenCount>0
输出示例
Result Set (43 items)
bug_id OpenCount <= like to add total activity records for bug
43350 3
62609 1
63961 1