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

Home -> Community -> Usenet -> c.d.o.server -> Complex decode help needed

Complex decode help needed

From: <c699484_at_showme.missouri.edu>
Date: Wed, 24 Jun 1998 21:12:04 GMT
Message-ID: <6mrq34$j7q$1@nnrp1.dejanews.com>


I'm trying to put together a report that is basically a table summarazing the ethnicity of some members of a database. Let's say I have a table like this:

 ID ETHNICITY AGE SEX

Where ethnicity is a code single character code from a lookup table.

I need to generate a report that looks something like this

             25 & Under 26 thru 30 31 thru 40 41 & over  Ethnicity Male | Fem. Male | Fem. Male | Fem. Male | Fem

I should note that this is simplified, I have 7 ethnicity codes and the age is actually just a birthdate stored as SYSDATE. NULL's are concievable, so I need to be sure that the statement doesn't return a value for a null field. Before discovering the power of decode, I created 70 some select count statements that correctly got each count..But that's WAY too many queries for our server, not to mention the time it'll take to generate that report.

Which finally brings me to my question; how can decode help me here? I'd have to nest a number of decode statements...Most of the examples I've seen are used to return a numeric code for each text string...I want to get a count for each column in that table.

Can someone get me started? I really appreciate it, and I know it's inconsiderate to ask this kind of question without posting code I've tried, but trust me, it wasn't even close to correct (:

 -Scott McCool

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Wed Jun 24 1998 - 16:12:04 CDT

Original text of this message

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