Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

select query inside hive not working

Highlighted

select query inside hive not working

New Contributor

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.