Re: [SQL] Group By Dilemma
От | Oliver Elphick |
---|---|
Тема | Re: [SQL] Group By Dilemma |
Дата | |
Msg-id | 199906040741.IAA04924@linda.lfix.co.uk обсуждение исходный текст |
Ответ на | Group By Dilemma ("Tim Perdue" <perdue@raccoon.com>) |
Список | 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. Theproblem 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 asolution.... > >SELECT >fld_mailid, >fld_mail_date, >fld_mail_is_followup, >fld_mail_from, >fld_mail_subject, <-- Grouponly 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.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver PGP key from public servers; key ID32B8FAA1 ======================================== "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
В списке pgsql-sql по дате отправления: