From: | Scott Ribe <scott_ribe(at)elevated-dev(dot)com> |
---|---|
To: | Postgresql General <pgsql-general(at)postgresql(dot)org> |
Subject: | sql query bug??? |
Date: | 2012-02-06 02:03:44 |
Message-ID: | 6B99BD95-8183-46CC-9EBB-A17FBA96DF04@elevated-dev.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Is this a bug (in 9.0.4), or have I just gone cross-eyed from too much work?
The query:
select t0."ICD9", t0."Description", count(*)
from (select distinct "Person_Id", "ICD9", "Description" from "PatientDiagnoses") as t0
group by (t0."ICD9", t0."Description")
order by count(*) desc limit 10;
The error:
column "t0.ICD9" must appear in the GROUP BY clause or be used in an aggregate function
Huh?
FWIW, I'm not providing the "PatientDiagnoses" def because it's a complex query involving 3-way union of 5-way joins--intended for end-user querying.
Of note, this query works (and performance is good enough as well):
select "ICD9", count(*) from (select distinct "Person_Id", "ICD9" from "PatientDiagnoses") as t0 group by "ICD9" order by count(*) desc limit 10;
--
Scott Ribe
scott_ribe(at)elevated-dev(dot)com
http://www.elevated-dev.com/
(303) 722-0567 voice
From | Date | Subject | |
---|---|---|---|
Next Message | Osmel Barreras Piñera | 2012-02-06 03:01:49 | SPI functions to work with the Execution Plan |
Previous Message | zhong ming wu | 2012-02-06 00:40:30 | Re: .psql_history file is messed up and control-r does not work |