一个疑问,我不是sql oracle的专家。我有以下sql:
select p.pname as Project, t.pname as Type, c.cname as component, w.timeworked/ 3600 as hours
from jira.jiraissue j,
jira.worklog w,
jira.project p,
jira.issuetype t,
jira.component c,
jira.nodeassociation na
where w.issueid = j.id
and J.PROJECT = P.ID
and na.source_node_id = j.id
AND na.sink_node_entity = 'Component'
AND na.source_node_entity = 'Issue'
and na.sink_node_id = c.id
and t.id = j.issuetype
and w.author = (case when $ {Author} = 'All' and then the author else $ {Author} ends)
and p.pname = (case when $ {Project} = 'All' then p.pname else $ {Project} final)
and t.pname = (case when $ {Type} = 'All' then t.pname else $ {type} final)
and c.cname = (case when $ {Component} = 'All' and then cname else $ {Component} final)
and to_char (w.startdate, 'yyyy-mm-dd')> = $ {FromDate}
and to_char (w.startdate, 'yyyy-mm-dd') <= $ {ToDate}
el resultado es la siguiente tabla:
我想添加一列,其中所有行的总和为HORAS,另一列中的总和为COMPONENTE分组。如果我可以做我想做的事和如何做,有人可以给我建议吗?
答案 0 :(得分:2)
分析功能可能会派上用场:
SELECT
p.pname AS Project,
t.pname AS Type,
c.cname AS component,
w.timeworked / 3600 AS hours,
SUM(w.timeworked / 3600) OVER () AS sum_all_hours,
SUM(w.timeworked / 3600) OVER (PARTITION BY c.cname) AS sum_by_component
FROM jira.jiraissue j
... (the rest of your current query)