在SQL中将两个查询的结果除以另一个查询

在SQL中将两个查询的结果除以另一个查询,sql,postgresql,Sql,Postgresql,我在元数据库中有此查询: with l1 as (SELECT date_trunc ('day', Ticket_Escalated_At) as time_scale, count (Ticket_ID) as chat_per_day FROM CHAT_TICKETS where SUPPORT_QUEUE = 'transfer_investigations' and date_trunc('month', TICKET_ESCALATED_AT) > n

我在元数据库中有此查询:

with l1 as (SELECT date_trunc ('day', Ticket_Escalated_At) as time_scale, count (Ticket_ID) as chat_per_day
    FROM CHAT_TICKETS where SUPPORT_QUEUE = 'transfer_investigations'
    and    date_trunc('month', TICKET_ESCALATED_AT) >  now() - interval '6' Month
    GROUP by 1)

with l2 as (SELECT date_trunc('day', created_date) as week, count(*) as TI_watchman_ticket
FROM jira_issues
WHERE issue_type NOT IN ('Transfer - General', 'TI - Advanced')
and    date_trunc('month', created_date) >  now() - interval '6' Month
and project_key  = 'TI2'
GROUP BY 1)

SELECT l1.* from l1
UNION SELECT l2.* from l2

ORDER by 1 
还有这个:

with hours as (SELECT date_trunc('day', ws.start_time) as date_
    ,(ifnull(sum((case when ws.shift_position = 'TI - Non-watchman' then (minutes_between(ws.end_time, ws.start_time)/60) end)),0) + ifnull(sum((case when ws.shift_position = 'TI - Watchman' then (minutes_between(ws.end_time, ws.start_time)/60) end)),0) ) as total
from chat_agents a
    join wiw_shifts ws on a.email = ws.user_email
    left join people_ops.employees h on substr(h.email,1, instr(h.email,'@revolut') - 1) = a.login
where     (seniority != 'Lead' or seniority is null)
    and    date_trunc('month', ws.start_time) >  now() - interval '6' Month
GROUP BY 1)   

我想将第一个联合体的输出除以第二个联合体的结果,任何想法。

我认为样本数据和期望的结果都会有所帮助,所以很清楚“除以”的含义。@GordonLinoff你是对的:第一个查询给出每日工作量单位,第二个查询给出团队完成的每日总小时数。所以我想得到每天,工作单位的总数,除以总小时数。了解完成一个单元需要多少时间