Skip site navigation (1) Skip section navigation (2)

Re: SUM() & GROUP BY

From: Richard Huxton <dev(at)archonet(dot)com>
To: Martin Kuria <martinkuria(at)hotmail(dot)com>
Cc: olly(at)lfix(dot)co(dot)uk, middink(at)indo(dot)net(dot)id, pgsql-sql(at)postgresql(dot)org
Subject: Re: SUM() & GROUP BY
Date: 2004-05-07 08:00:43
Message-ID: 409B422B.6080502@archonet.com (view raw or flat)
Thread:
Lists: pgsql-sql
Martin Kuria wrote:
> Hi again I have two tables I would like to query i.e. service table and 
> division table
> 
> SELECT s.pd_geo, COUNT(s.pd_geo) FROM ser s GROUP BY s.pd_geo;
> OUTPUT:
> pd_geo | count
> ----------------------
>  1        |   49
>  2        |   39
>  3        |    6
>  4        |    54
> 
> SELECT d.divisions_name, d.divisions_id)
> FROM ser s, ser_divisions d
> WHERE d.divisions_id = s.ser_divisions;
> 
> division_name | divisions_id
> --------------------------------------
>  DEC            |   6
>  DEPI           |   7
>  DRC            |    8
> 
> How can I create a query that displays  How the divisions answered the 
> question please do assist.

Martin - you'll need to explain exactly what you want. Can you show what 
  outputs you would like given the above data?

-- 
   Richard Huxton
   Archonet Ltd

In response to

pgsql-sql by date

Next:From: Freddy Villalba AriasDate: 2004-05-07 08:20:52
Subject: EXPORT / IMPORT
Previous:From: Martin KuriaDate: 2004-05-07 06:47:35
Subject: Re: SUM() & GROUP BY

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group