错误查询:
select a.create_date ,count(*)
from (
select TB1.create_date
from TB1 join TB2on (
TB1.wrapperid = TB2.wrapperid
and TB1.id=TB2.id )
where TB2.status!='1'
and TB1.create_date >='2014-06-01'
) a
group by a.create_date
order by a.create_date 报错信息:
FAILED: SemanticException [Error 10004]: Line 1:347 Invalid table alias or column reference 'a': (possible column names are: create_date ,
_c1)
查询改为:
select a.date,count(*)
from (
select TB1.create_date as date
from TB1 join TB2 on (
TB1.wrapperid = TB2.wrapperid
and TB1.id=TB2.id )
where TB2.status!='12'
and TB1.create_date >='2014-06-01'
) a
group by a.date
order by a.date
本文介绍了一个SQL查询语句中出现的错误及修正方法。原始查询因无效的表别名引用导致失败,通过调整别名使用并更改部分条件,成功解决了问题。

被折叠的 条评论
为什么被折叠?



