Reply
New Contributor
Posts: 1
Registered: ‎02-14-2019

select query inside hive not working

Hi,

 

My problem statement is like 

 

"Find top 2 districts per state with the highest population"

 

data is like

 

State   dist       popul

TN       MDU    100

TN       CHE     200

TN       CBE     150

KL        AA        250

KL        BB        100

KL        CC        300

 

My expected output is

 

State  dist 

 

TN      CHE, CBE

KL       CC, AA

 

I tried this with lot of queries and sub-queries but results in SQL error with the sub query

 

Can anyone help me with getting this result?

 

Thanks in advance.

 

Announcements

Our community is getting a little larger. And a lot better.


Learn More about the Cloudera and Hortonworks community merger planned for late July and early August.
New solutions