请尝试以下sql,若要执行此查询,您需要使用“输入日期”加入所有团队成员和单个团队成员的结果集
SELECT individual_count.in_date,
TO_CHAR( individual_count.sum_in_count * 100 / all_count.sum_in_count , '99.99') AS "Team percentage"
FROM
(SELECT SUM(IN_COUNT) AS sum_in_count,
in_date
FROM <in_table>
WHERE in_date BETWEEN TO_DATE(:P2_FROM, 'MM/DD/YYYY') AND TO_DATE(:P2_TO, 'MM/DD/YYYY')
AND username = :P2_USER
GROUP BY in_date
) AS individual_count
INNER JOIN
(SELECT SUM(IN_COUNT) AS sum_in_count,
in_date
FROM <in_table>
WHERE in_date BETWEEN TO_DATE(:P2_FROM, 'MM/DD/YYYY') AND TO_DATE(:P2_TO, 'MM/DD/YYYY')
GROUP BY in_date
) AS all_count
ON individual_count.in_date = all_count.in_date;