2011-03-16 6 views
0

오류가 발생합니다 : Every derived table must have its own alias 하지만 누락 된 별칭이 어디 있는지 알 수 없습니다. 내가 찾도록 도와 줄 수 있니?누락 된 테이블 별칭을 찾을 수 없습니다

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 

답변

1

하지이 라인 해야하는

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 
+0

아무런 효과가없는 것 같습니다. – Ramy

+0

그리고 일부 브래킷 문제가 있습니다 (답변 참조) – Nanne

+0

와우, 나는 적어도 세 번 이상 그 괄호를 세었습니다 .... – Ramy

1

괄호를 계산하여 시작하십시오.

15 개의 열린 괄호와 16 개의 닫힌 괄호가 있습니다.

관련 문제