查询语句可以直接使用非分析函数的变量的别名

select t1.*
from 
(
select account_id, sum(recharge_money) recharge_money_total
from dw.dw_app 
where dt='2016-11-21' 
and app_id='2137'
and msgtype = 'role.recharge' 
group by account_id
order by recharge_money_total desc
limit 10000000
) t1
limit 10;

 

 

分析函数必须套一个查询,不能直接用rn <=5

select t1.*
from 
(
select account_id, sum(recharge_money) recharge_money_total, 
  row_number() over (order by sum(recharge_money) desc) as rn
from dw.dw_app 
where 
dt='2016-11-21' 
and app_id='2137'
and msgtype = 'role.recharge' 
group by account_id
) t1
where t1.rn <= 5

 

相关文章:

  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2021-06-04
  • 2021-07-12
  • 2021-06-07
  • 2022-12-23
猜你喜欢
  • 2022-01-18
  • 2021-10-15
  • 2021-05-08
  • 2021-05-10
相关资源
相似解决方案