开发者

can't find the missing table alias

i'm getting the error: Every derived table must have its own alias but i fail to see where the missing alias is. can you help me find it?

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 


Shouldn't this line

having avg(current_test) > 200000 ) as b  

be

 having avg(current_test) > 200000 ) b

there is also a closing bracket too many (or an opening too less). The first one matches with the one before the last one in this line:

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


Start by counting your parentheses.

You have 15 open parens and 16 close parens.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜