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

Group By Statement - how to display fields not in the statement?

From: lcp_ <lcpsignup(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Group By Statement - how to display fields not in the statement?
Date: 2009-08-21 23:50:52
Message-ID: 25089050.post@talk.nabble.com (view raw or flat)
Thread:
Lists: pgsql-novice

I have the following query:

SELECT count(*), address, organizati FROM afterschool
WHERE verified IS TRUE
Group BY address, organizati HAVING count(*) >1

I would like to have the individual records from this query display with
other fields not in the Group By clause. If I try to add other fields to the
select statement I get this error:

ERROR: column "afterschool.firstname" must appear in the GROUP BY clause or
be used in an aggregate function

Any ideas on how I can both Group By these fields and limit to counts of
more than one, and also display the records with more than just the fields I
am grouping by?
-- 
View this message in context: http://www.nabble.com/Group-By-Statement---how-to-display-fields-not-in-the-statement--tp25089050p25089050.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


Responses

pgsql-novice by date

Next:From: Joshua TolleyDate: 2009-08-22 04:55:37
Subject: Re: Group By Statement - how to display fields not in thestatement?
Previous:From: David SaraciniDate: 2009-08-21 04:58:32
Subject: pg_dump

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