简体   繁体   English

如何使用别名解释此 SQL 错误?

[英]How do I interpret this SQL error with alias name?

I'm trying to run some code with a subquery but I'm not able to figure out why I'm getting an error.我正在尝试使用子查询运行一些代码,但我无法弄清楚为什么会出现错误。

select efile.*
from    
        (select can, 
        sum(case when tax_year = 2018 then IND_RETURNS_IN_SEASON+IND_RETURNS_EXT_SEASON else 0 end) as TY18_efiles,
        sum(case when tax_year = 2019 then IND_RETURNS_IN_SEASON+IND_RETURNS_EXT_SEASON else 0 end) as TY19_efiles
        from pcg_dm.ENT_AGG_CUST_MEASURES
        where can in 
                (select distinct can
                from pcg_dm.ENT_AGG_CUST_MEASURES
                where tax_year in (2019,2019)
                )
        group by 1
        order by 1
        limit 2000
        ) AS efile
join    
        (select can, st.STATE AS TY18_state
        from pcg_dm.ENT_AGG_CUST_ATTRIBUTES AS st
        where tax_year = 2018
        limit 2000
        )AS 18State
        
on
         efile.can=18state.can

I get the following error.我收到以下错误。

[Code: 4856, SQL State: 42601] [Vertica]VJDBC ERROR: Syntax error at or near "18" [代码:4856,SQL State:42601] [Vertica]VJDBC 错误:“18”处或附近的语法错误

Any idea what the issue is?知道问题是什么吗?

You gave an alias name for the table in Line number 18 after the from clause.您在 from 子句后的第 18 行中为表指定了别名。 Try removing that and re-run the query.尝试删除它并重新运行查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM