SELECT CASE STATUS
WHEN 'active' THEN '已激活'
WHEN 'resolved' THEN '已解决'
WHEN 'closed' THEN '已关闭'
ELSE '其他'
END AS "类别", count(*) AS "数量"
FROM zt_bug
WHERE datediff(NOW(), openedDate) <= 30
GROUP BY STATUS
■ 近14天的Bug状态
SELECT DISTINCT DATE_FORMAT(openedDate, '%Y-%m-%d') AS "时间"
, (
SELECT count(*)
FROM zt_bug z1
WHERE status = 'active'
AND DATE_FORMAT(z1.openedDate, '%Y-%m-%d') = DATE_FORMAT(z2.openedDate, '%Y-%m-%d')
) AS "已激活"
, (
SELECT count(*)
FROM zt_bug z1
WHERE status = 'resolved'
AND DATE_FORMAT(z1.openedDate, '%Y-%m-%d') = DATE_FORMAT(z2.openedDate, '%Y-%m-%d')
) AS "已解决"
, (
SELECT count(*)
FROM zt_bug z1
WHERE status = 'closed'
AND DATE_FORMAT(z1.openedDate, '%Y-%m-%d') = DATE_FORMAT(z2.openedDate, '%Y-%m-%d')
) AS "已关闭"
FROM zt_bug z2
WHERE datediff(NOW(), z2.openedDate) <= 14
ORDER BY z2.openedDate DESC
■ 产品数据
SELECT DISTINCT zp.NAME AS "产品名称"
, (
SELECT count(*)
FROM zt_productplan zpp
WHERE zp.id = zpp.product
) AS "计划数"
, (
SELECT count(*)
FROM zt_story zs
WHERE zp.id = zs.product
) AS "创建需求数"
, (
SELECT count(*)
FROM zt_story zs
WHERE zp.id = zs.product
AND zs.`status` = 'closed'
) AS "完成需求数"
FROM zt_product zp
■ 项目数据
SELECT DISTINCT zp.NAME AS "项目名称"
, (
SELECT count(*)
FROM zt_story zs
LEFT JOIN zt_projectstory zpjs ON zpjs.story = zs.id
WHERE zs.STATUS = 'closed'
AND zpjs.project = zp.id
) AS "完成需求数"
, (
SELECT count(*)
FROM zt_task zt
WHERE zt.project = zp.id
AND zt.`status` = 'done'
) AS "完成任务数"
, (
SELECT count(*)
FROM zt_bug zb
WHERE zb.project = zp.id
AND zb.`status` = 'resolved'
) AS "解决Bug数"
FROM zt_project zp
■ 近30天的需求状态分布
SELECT CASE stage
WHEN 'wait' THEN '等待中'
WHEN 'planned' THEN '已计划'
WHEN 'projected' THEN '已立项'
WHEN 'developing' THEN '开发中'
WHEN 'testing' THEN '测试中'
WHEN 'verified' THEN '已验收'
WHEN 'closed' THEN '已关闭'
ELSE '其他'
END AS "类别", count(*) AS "数量"
FROM zt_story
WHERE datediff(NOW(), openedDate) <= 30
GROUP BY stage
■ 近14天的需求状态
SELECT DISTINCT DATE_FORMAT(openedDate, '%Y-%m-%d') AS "时间"
, (
SELECT count(*)
FROM zt_story z1
WHERE stage = 'planned'
AND DATE_FORMAT(z1.openedDate, '%Y-%m-%d') = DATE_FORMAT(z2.openedDate, '%Y-%m-%d')
) AS "已计划"
, (
SELECT count(*)
FROM zt_story z1
WHERE stage = 'wait'
AND DATE_FORMAT(z1.openedDate, '%Y-%m-%d') = DATE_FORMAT(z2.openedDate, '%Y-%m-%d')
) AS "等待中"
, (
SELECT count(*)
FROM zt_story z1
WHERE stage = 'developing'
AND DATE_FORMAT(z1.openedDate, '%Y-%m-%d') = DATE_FORMAT(z2.openedDate, '%Y-%m-%d')
) AS "研发中"
, (
SELECT count(*)
FROM zt_story z1
WHERE stage = 'testing'
AND DATE_FORMAT(z1.openedDate, '%Y-%m-%d') = DATE_FORMAT(z2.openedDate, '%Y-%m-%d')
) AS "测试中"
, (
SELECT count(*)
FROM zt_story z1
WHERE stage = 'verified'
AND DATE_FORMAT(z1.openedDate, '%Y-%m-%d') = DATE_FORMAT(z2.openedDate, '%Y-%m-%d')
) AS "已验收"
FROM zt_story z2
WHERE datediff(NOW(), z2.openedDate) <= 14
ORDER BY z2.openedDate DESC