select
t.app_type,
t.cnt,
(cast(t.cnt as double)/cast(all.all_count as double)) as percent
from
(
select
app_type,
count(*) as cnt
from
xxx
where
dt='2022-02-26'
group by
app_type
) t
cross join (
select
count(*) as all_count
from
xxx
where
dt='2022-02-26'
) all
order by
t.cnt desc
limit
6;
报错:
Error: Error while compiling statement: FAILED: ParseException line 4:60 cannot recognize input near 'as' 'percent' 'from' in selection target (state=42000,code=40000)
然后 把 as percent 去掉后,暂且能跑通了。
疑问:为什么 as percent 设置一个别名,那个SB SQL 就报错了呢?
解答:all、percent 都是关键字(保留字)。



