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: SQL QUERIES ... EXPERT HINTS NEEDED !

Re: SQL QUERIES ... EXPERT HINTS NEEDED !

From: xiong feng <xiong_at_meibm7.cen.uiuc.edu>
Date: 1997/07/08
Message-ID: <5pu7v4$f3r$1@vixen.cso.uiuc.edu>#1/1

"miguel" <jmiguel_at_cet.pt> writes:

>1) Query needed: Given one District (DD=x) , obtain Post Office count,
>and total Population, for all counties (grouped by Counties).
 

>2) Can this be done in a single query ?
 

>I have tried several queries and I usually get the right count of Post
>Offices but I get huge Sums of population. It seems that it keeps adding up
>the population of a same town, for every ocurrence of a Post Office. How
>can I solve this redundancy problem ?

Try this and see if it works:

select cc, count(po_id), sum(pop) from demog, post where demog.tt = post.tt and dd = 'x'
group by cc;

--
____   __   ___   ___  ====== Feng Xiong =========== xiong_at_uiuc.edu =====
   /  /  | |   |    /   Traded left kidney for |  Will now trade spleen
 \/      | |   |   /\       Marmalade Boy...   |       for Kodocha!
  \   __/  |___|  /  \ ============= http://jac.anime.net/ ==============
Received on Tue Jul 08 1997 - 00:00:00 CDT

Original text of this message

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