Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL QUERIES ... EXPERT HINTS NEEDED !
"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