hadoop

[hive] group by 이후에 order by 개수 지정하기

'김용환' 2016. 4. 19. 15:23



hive에서 count를 사용하기 위해 group by 컬럼을 적용한 후 order by 컬럼을 사용할 때 사용할 팁이다.



특정 필드를 기반으로 group by 후, count 별 역순으로 확인할 때, 

order by 뒤에 들어갈 필드는 count(*)에 대한 앨리어스를 사용하면 잘된다.


select timezone, count(*) as count from request where date=20160401

 group by timezone order by count desc limit 30