苏木木夕 2018-12-10 11:47 采纳率: 0%
浏览 386

我的SQL代码执行结果为空,没报错。【有好答案我可以加悬赏,求助!】

我的这段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的变量。

  • 写回答

1条回答 默认 最新

  • lshen01 2023-03-15 18:32
    关注

    参考GPT和自己的思路:

    针对你的问题,我可以提供以下回答:

    (1)对于代码的优化,首先建议对代码进行排查和调试,检查表之间的关联关系和查询条件是否正确,以及是否有数据丢失、重复等问题。其次,可以考虑对查询语句进行简化,避免不必要的嵌套和重复操作。另外也可以对表进行合并或者使用索引等方式来优化代码执行效率。

    (2)造成结果为空的原因可能有很多,需要具体排查。可能是原始数据表中没有符合查询条件的数据,也可能是查询结果被误归为NULL或者空值,还有可能是查询结果存在错误但是没有被报错。建议根据具体情况进行调试和修改代码。

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog