Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: compute sum on VACHAR column

Re: compute sum on VACHAR column

From: G Quesnel <dbaguy_ott_at_yahoo.com>
Date: 19 Apr 2006 09:39:16 -0700
Message-ID: <1145464756.122875.107880@e56g2000cwe.googlegroups.com>


To sum up counts, you can use the rollup option in the group by clause.
As in Select gender,count(*) from ... group by rollup(gender). Have you looked at the decode function ? You could do something like ...
Select sum (Male), sum(Female),

          sum(Male+Female), sum(Male)/sum(Male+Female) from (select decode(gender,'M',1,0) Male, decode(gender,'F',1,0) Female

         from ... where ...) T_in
Note that you don't have to use an inline query, but it simplifies the logic Received on Wed Apr 19 2006 - 11:39:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US