Search Postgresql Archives

Re: A select DISTINCT query? - followup Q

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



People,


> select count(*) as cnt, name from tst group by name having count(*) = 1


This worked for my basic example but not for my actual problem - I get
"column comment must appear in the GROUP BY clause or be used in an
aggregate function" errors so I have a related question:

With table:

name comment

1    first comment
2    second comment
3    third comment
3    fourth comment
4    fifth comment
5    sixth comment

- how can I use something like the previous select statement but where
the comment field does not appear in the "group by" clause and gives the
following result:

1    first comment
2    second comment
4    fifth comment
5    sixth comment

Thanks,

Phil.
-- 
Philip Rhoades

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW      2001
Australia
Fax:     +61:(0)2-8221-9599
E-mail:  phil@xxxxxxxxxxxxx


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux