我的表格如下所示
project|issue|status |story_points|sprint |date |active_sprint
===============================================
FB1 |abc |In Review| 3 |Backlog|2017-06-05|True
FB1 |acc |In Review| 3 |Backlog|2017-06-05|True
FB1 |adc |In Review| 3 |Backlog|2017-06-04|True
FB2 |xyz |In Review| 3 |Backlog|2017-06-05|True
预期结果
open|project|date
===============================================
6 |FB1 |2017-06-05
3 |FB1 |2017-06-04
3 |FB2 |2017-06-05
我已经尝试了很长一段时间并且看了一遍,但仍然无法弄明白这一点。我对postgres和观点都相当新,并希望得到一些帮助。我已经尝试了很多不同的变体,但我仍然无法使其发挥作用。
SELECT
(SELECT COALESCE(SUM(story_points),0) AS "Open" from sample_table WHERE project = 'FB1' AND active_sprint='True' AND (status = 'In Review')) as "Open",
(SELECT 'FB1'::text AS "Project") as "Project",
(SELECT date as Date) as Date from sample_table WHERE project = 'FB1' group by 3
答案 0 :(得分:0)
您可以尝试这样的事情:
select project, date1 , sum(story_points)
from asd1
group by project, date1