0
我有一個表,看起來像下面Postgres的查看 - 總和,其中日期是所有的值相同
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
我可能是有點困惑。不能這只是通過 SELECT SUM(story_points),項目,日期 FROM sample_table GROUP BY 2,3 – Tik