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: Intermediate SQL problem

Re: Intermediate SQL problem

From: Sybrand Bakker <postmaster_at_sybrandb.demon.nl>
Date: Wed, 8 Dec 1999 23:29:36 +0100
Message-ID: <944692220.7551.0.pluto.d4ee154e@news.demon.nl>


Definitely homework, but here is a starter select st_abbrev, sum(decode(gender,'M',0,selected)) "Total Male", sum(decode(gender,'F',selected,0)) "Total Female",sum(selected) selected from population
group by st_abbrev.
You get the picture probably...
Hth,

--
Sybrand Bakker, Oracle DBA
<nameproliferation_at_my-deja.com> wrote in message news:82mirm$ql1$1_at_nnrp1.deja.com...
> Hello,
>
> I'm hoping someone can help me formulate the SQL I need to do this
> report.
>
> I have to calculate statistics off a single table, listed by state, on
> another table:
>
> STATE ( st_abbrev, st_name );
> POPULATION ( process_id, st_abbrev, gender, err_code, selected );
>
> I need the count, by state, of each of the field values. The report
> header looks like:
>
> Process: XXX
> State Total Population Total Male Total Female Total Selected \
> ===== ================ ========== ============ ============== \
>
> Total Male Selected Total Female Selected Error Code Error Total
> =================== ===================== ========== ===========
>
> Note that the last 2 fields are really a table in a table!
>
> Sheesh!
>
> I think this can be done in 1 select (esp. if the error part is
> dropped), but I'm having a real problem. Can someone help!??
>
> Thanks much!
> -=np=-
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Wed Dec 08 1999 - 16:29:36 CST

Original text of this message

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