Group By Dilemma

From: "Tim Perdue" <perdue(at)raccoon(dot)com>
To: <pgsql-sql(at)hub(dot)org>
Subject: Group By Dilemma
Date: 1999-06-04 01:47:30
Message-ID: 001801beae2c$354dd580$0b8c5aa5@timnt.weather.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello, I am trying to do a GROUP BY so that I can get a count of messages
with the same subject. The problem is, the optimizer won't let me group by
just one column, when I am selecting several columns.

I suppose Postgres doesn't know which rows to leave out and which ones to
display, but I'm hoping someone can offer a solution....

SELECT
fld_mailid,
fld_mail_date,
fld_mail_is_followup,
fld_mail_from,
fld_mail_subject, <-- Group only on this, so I can get a count
count(*)
FROM tbl_mail_archive
WHERE fld_mail_list=1 AND
fld_mail_year=1999 AND
fld_mail_month=06
group by fld_mail_subject
ORDER BY fld_mail_date DESC
LIMIT 26 OFFSET 0;

Tim Perdue
PHPBuilder.com / GotoCity.com / Geocrawler.com

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Bitmead 1999-06-04 03:18:53 Slashdot Query
Previous Message Mark Wright 1999-06-03 20:39:19 I'm causing deadlocks!