pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Ellerbrock <richarde@eskom.co.za>
To: chriskl@familyhealth.com.au
Cc: pgsql-sql@postgresql.org
Subject: Re: REPOST: Trouble with SQL conversion
Date: Thu, 11 Apr 2002 16:08:38 +0200
Message-ID: <scb5b513.058@eskom.co.za> (raw)

Ok, did that - now it works but returns no records.

What I am after is to reduce the right hand table to one row matching
the left table. There may be no, one or many matching records in the
right table, but I want to group them on the key and find out the number
of records in the right table at the same time.

This works just fine in that other database :-)

>>> Christopher Kings-Lynne <chriskl@familyhealth.com.au> 2002/04/11
03:28:32 >>>
> SELECT base.baseindex, base.subnetsize, base.descrip, base.baseaddr,
> base.admingrp, count(ipaddr.baseindex) AS cnt FROM base
> LEFT JOIN ipaddr ON base.baseindex=ipaddr.baseindex WHERE
> base.baseaddr
> BETWEEN 2473473024 AND 2473473151 AND base.customer=1
> GROUP BY base.baseindex
> ORDER BY base.baseaddr;

> 0: ERROR: Attribute base.subnetsize must be GROUPed or used in an
> aggregate function

Do what it says.  Add base.subnetsize to the GROUP BY.  You'll
probably
need to add base.descrip, base.baseaddr and base.admingrp as well.

Chris




view thread (6+ messages)  latest in thread

Message-ID: <scb5b513.058@eskom.co.za>
Permalink:  ../scb5b513.058@eskom.co.za/
Also on:    postgresql.org/message-id/scb5b513.058@eskom.co.za

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: richarde@eskom.co.za, chriskl@familyhealth.com.au
  Subject: Re: REPOST: Trouble with SQL conversion
  In-Reply-To: <scb5b513.058@eskom.co.za>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox