Use a join as given below, I have used the table name temp.

select a.Category, a.count, b.tot_count, (100*a.count)/tot_count as
percent_count
from   ( select Category, count(*) as count from temp group by Category ) a
    join (select count(*) as tot_count from temp) b
     on (true)

Hope this helps
Nanda Vijaydev

On Mon, May 28, 2012 at 3:28 PM, Igor Tatarinov <i...@decide.com> wrote:

> Try replacing the comma with JOIN
>
> igor
> decide.com
>
> On Mon, May 28, 2012 at 6:48 AM, shan s <mysub...@gmail.com> wrote:
>
>> 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
>>
>
>

Reply via email to