首先想到的方式 直接限制
select
a.projectid
,DIM.projectname
,DIM.areaname
,to_char(a.msgtimestamp,'yyyyMMdd')
--,count(a.id)
,count(1) --客户询问数目
,count(b.id) --24小时回复数目
from ods.xk_c_user_broker_chat_records a --来询问人记录
inner join ods.xk_a_broker_user a1
on a.from_account=a1.id
left join ODS.XK_B_PROJECT DIM
ON A.projectid = DIM.id
left join ods.xk_c_user_broker_chat_records b
on a.conversationid=b.conversationid
and b.msgtimestamp>=a.msgtimestamp
and b.msgtimestamp<=a.msgtimestamp + INTERVAL '24' HOUR
and b.DataType not IN ('system', 'timeoutMsg' )
-- inner join ods.xk_b_account c
-- on c.id=b.to_account
-- and c.status=1
-- and c.isdel=0
where a.projectid='01802085-5D6