我的这段SQL代码,执行了1个小时,没有报错,但是最终结果是“空”,求助。
(1)这段代码应该怎么优化?
(2)这段代码为什么执行完是空?
with sanlian as (
select uuid, att_user, intrst_user, inten_user, car_owner, top1att, top3att, top5att, hour_prf, level_prf, series_prf, spec_prf, brand_prf, place_prf, price_prf, leads_num, leads_series
from AA表
where uuid in(select distinct uuid from AA表) and substr(dt,1,7) = '2018-10'
),
fulltable as(
select uuid, age_age as age,
sex_sex as sex,
car_loan as car_loan,
mortgage as mortgage,
er_value as customer_value,
du_level as edu_level,
ge_name as stage,
occupation as occupation,
tal_status as marital_status,
illing as loan_willing,
city as city,
concen as concen,
interval_day as interval_day
from BB表
where seri = '1'
),
atttime as(
select b.uuid, a.att_time
from(
( select uuid, cookie from CC表) b
join
(select cookie, sum(att_time) as att_time
from DD表
where substr(dt,1,7) = '2018-10' cookie <> '0'
group by cookie
) a
on a. cookie = b.cookie
)
),
inten as (
select b.uuid, a.ordernum
from(
(
select phone, sum(ordernum) as ordernum
from EE表
where substr(dt,1,7) = '2018-10' and series_id = '1'
group by phone
) a
join
(
select uuid, phone
from FF表
)b
on a.phone = b.phone
)
),
fangwen as(
select uuid, y_id, y_name, sum(y_ratio) as y_ratio, sum(n_ratio) as n_ratio
from GG表
where substr(dt,1,7) = '2018-10' and series_id = '1'
group by uuid, y_id, y_name
)
select *
from sanlian as a
left join atttime as e
on a.uuid = e.uuid
full join intention as b
on a.uuid = b.uuid
left join fangwen as f
on a.uuid = f.uuid
join fulltable as g
on a.uuid = g.uuid
最后*是35个来自a\b\e\f\g的变量。