gpt4 book ai didi

mysql - 找不到丢失的表别名

转载 作者:行者123 更新时间:2023-11-29 09:11:56 25 4
gpt4 key购买 nike

我收到错误:每个派生表必须有自己的别名但我看不到丢失的别名在哪里。你能帮我找到它吗?

select *
from
(select distinct brand.industry, cur.subindustry, brand.brand, dims.activity, dims.detail, cur.referral_source
from
referraldb.report_referral_db_viz_qa cur
inner join referraldb.report_referral_db_viz_qa prv
on cur.report_time_id = prv.report_time_id
and cur.dimension_id = prv.dimension_id
and cur.brand_id = prv.brand_id
and cur.referral_source = prv.referral_source
and cur.date = date_add(LAST_DAY(DATE_SUB(@d, INTERVAL 1 month)), interval 1 day)
and prv.date = date_add(LAST_DAY(DATE_SUB(@d, INTERVAL 2 month)), interval 1 day)
inner join referraldb.dim_all_dimensions dims
on dims.dimension_id = prv.dimension_id
inner join referraldb.dim_brand brand
on brand.brand_id = prv.brand_id
where
dims.lag = 'immediate'
and dims.measure_type = 'visits'
and prv.subindustry = 'flight'
and prv.report_time_id = 1
and abs((((cur.current_test - prv.current_test)/cur.current_test) * 100)) >= 30)) a
inner join
(select fact.referral_source, brand.Industry, fact.subindustry, brand.Brand, dims.Activity, dims.Detail
from
referraldb.report_referral_db_viz_qa fact inner join
referraldb.dim_brand brand
on brand.brand_id = fact.brand_id inner join
referraldb.dim_report_time t
on t.report_time_id = fact.report_time_id inner join
referraldb.dim_all_dimensions dims
on dims.dimension_id = fact.dimension_id
where dims.lag = 'Immediate' and dims.measure_type = 'Visits' and fact.subindustry = 'flight' and fact.report_time_id = 1 and fact.date > DATE_SUB(NOW(), INTERVAL 14 month)
group by fact.referral_source, brand.Industry, fact.Subindustry, brand.Brand, dims.Activity, dims.Detail
having avg(current_test) > 200000 ) as b
on a.industry = b.industry and a.subindustry = b.subindustry and a.brand = b.brand and a.activity = b.activity and a.detail = b.detail and a.referral_source = b.referral_source

最佳答案

这行不应该

having avg(current_test) > 200000 ) as b  

 having avg(current_test) > 200000 ) b

还有一个右括号太多(或者一个左括号太少)。第一个与该行中最后一个之前的匹配:

and abs((((cur.current_test - prv.current_test)/cur.current_test) * 100)) >= 30)) a

关于mysql - 找不到丢失的表别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5331499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com