sql query bug???

Поиск
Список
Период
Сортировка
От Scott Ribe
Тема sql query bug???
Дата
Msg-id 6B99BD95-8183-46CC-9EBB-A17FBA96DF04@elevated-dev.com
обсуждение исходный текст
Ответы Re: sql query bug???  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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--intendedfor 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
bycount(*) desc limit 10; 

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice





В списке pgsql-general по дате отправления:

Предыдущее
От: zhong ming wu
Дата:
Сообщение: Re: .psql_history file is messed up and control-r does not work
Следующее
От: Osmel Barreras Piñera
Дата:
Сообщение: SPI functions to work with the Execution Plan