hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shan s <mysub...@gmail.com>
Subject Need help with simple subquery
Date Mon, 28 May 2012 13:48:09 GMT
I need help with a simple subquery. Given below data, I need counts and
percentage counts per category. (Re-phrasing my earlier question )
With the code below I get an error: *FAILED: Parse Error:* line 6:50
*mismatched
input ','* *expecting EOF near 'a'*

Looking at the documentation the syntax it is not clear to me.. In the form
clause, can I have multiple selects and just alias them and use them in the
top query?
If so, what am I missing in the below code...

select a.category, a.count, b.totalCount
from
(select category, count(*) as count from gt group by category) a,
(select count(*) as totalCount from gt) b ;

Many Thanks,
Prashant.

Id Category         Count Output   Percentage Output
1    A                    A      4             A     40 (4/10)*100
2    A                    B      3             B     30
3    B                    C      3             C     30
4    A
5    C
6    C
7    B
8    B
9    A
10  C

Mime
View raw message