i am using the following query:
select country_name from (SELECT country_name, rank() OVER (ORDER BY TOTAL_pop desc)
as rk FROM (SELECT country_name, sum(col8) as TOTAL_pop FROM world_bank_data_partitioned GROUP BY country_name)
) SUM_EMP where rk = 2;
and getting the following error:
Error while compiling statement: FAILED: ParseException line 1:197 cannot recognize input near ')' 'SUM_EMP' 'where' in subquery source
Please help me with the same.
You can use below SQL. You need to alias each subquery. I name the subquery as
rs
.