From: | "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | "Tim Perdue" <perdue(at)raccoon(dot)com> |
Cc: | pgsql-sql(at)hub(dot)org |
Subject: | Re: [SQL] Group By Dilemma |
Date: | 1999-06-04 07:41:52 |
Message-ID: | 199906040741.IAA04924@linda.lfix.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"Tim Perdue" wrote:
>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.
You can only have the grouped column and aggregates in your query.
>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;
What do you expect to see in the other columns? Why are you including
them at all?
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP key from public servers; key ID 32B8FAA1
========================================
"But without faith it is impossible to please him; for
he that cometh to God must believe that he is, and
that he is a rewarder of them that diligently seek
him." Hebrews 11:6
From | Date | Subject | |
---|---|---|---|
Next Message | Vikrant Rathore | 1999-06-04 08:01:31 | Mail about select |
Previous Message | nathan | 1999-06-04 05:17:23 | Embedded SQL in 'C' |