Group By Dilemma - Mailing list pgsql-sql

From Tim Perdue
Subject Group By Dilemma
Date
Msg-id 001801beae2c$354dd580$0b8c5aa5@timnt.weather.net
Whole thread Raw
Responses Re: [SQL] Group By Dilemma
List 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





pgsql-sql by date:

Previous
From: "Mark Wright"
Date:
Subject: I'm causing deadlocks!
Next
From: Chris Bitmead
Date:
Subject: Slashdot Query