我把 query 做了些改写,你看看是否满足需求,理论上要比原来的写法好些:
match (m:`USER`)-[r1:CALL_TO]-(x:MOBILE),
(x)-[:APPLY_FOR]->(:APPL)-[:APPLY_ON]-(t1:`TIME`),
(x)-[r2:CALL_TO]-(n:`USER`)
where id(m) in ["1510615318"] AND
r1.first_callmark_on<=20220102 AND
t1.`TIME`.`date` < '2022-01-02' AND
r2.first_callmark_on<=20220102 and
id(n)<>'1510615318'
with distinct id(x) as xid,
id(n) as nid,
case when "MOBILE" in labels(n) then 1 else 0 end as mobile
return count(xid) as n_appl_1st_v4,
count(nid) as n_user_2nd_v4,
sum(mobile) as col_mobile_2nd_v4