Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to calculate the total of a varchar column?
In article <1139846992.606755.128210_at_g47g2000cwa.googlegroups.com>,
mpkrishna25_at_yahoo.com says...
> Hello,
>
> I have a column named Gender in my table. Its a varchar2 type column
> and each row is either 'M' or and 'F'. I want to count the no. of Ms
> and number of Fs and obtain the result of the number of Ms and Fs in a
> separate row.
>
> Right now I am only able to perform the count function and obtain the
> number of Ms and Fs. But I am not able to get the total for Ms and Fs.
> So can some one please tell me how should I do it?
>
> Right now I am giving the following command:
>
> SELECT GENDER, COUNT(GENDER) As American_Indian
> FROM STUDENT_DETAIL
> WHERE ETHNIC_GROUP_CODE = 1
> GROUP BY GENDER ORDER BY GENDER DESC
>
> And the output is coming as
>
> Gender American_Indian
> -----------------------------------------
> M 60
> F 60
>
> What I want to see is
>
> Gender American_Indian
> -----------------------------------------
> M 60
> F 60
> MF 120
>
> Please help.
>
select GENDER, COUNT(GENDER)
from...
group by rollup(gender)
Regards,
Jan
Received on Sat Feb 18 2006 - 04:53:09 CST