Re: Help with query

Поиск
Список
Период
Сортировка
От Christian Hofmann
Тема Re: Help with query
Дата
Msg-id 00ba01c61a09$96998870$9000a8c0@taschenrechner
обсуждение исходный текст
Ответ на Re: Help with query  (Andreas Kretschmer <akretschmer@spamfence.net>)
Ответы Re: Help with query  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-novice
Hello Andreas,


> Why is project_name for a given project_no different? I
> think, you have a wrong data-model.

I updated the project_name. It is the same when it were a address table
customers storing their addresses and later I update some values when they
move to an other city.

> select pnr, max(ts) from p where ts < '2006-01-15 17:06:00'
> and pnr not
> in (select pnr from p where op = 'D' and ts < '2006-01-15 17:06:00')
> group by pnr;

I tried to use this on my table:

select project_no, project_name, max(stamp) from p01_projects_his where
stamp < '2006-01-15 17:06:00' and project_no not
in (select project_no from p01_projects_his where operation = 'D' and stamp
< '2006-01-15 17:06:00') group by project_no;


I added project_name because I want to have this row too (to see what it is
at this time). But now I get the following error:


ERROR:  column "p01_projects_his.project_name" must appear in the GROUP BY
clause or be used in an aggregate function

Do you know how to solve this error? I need this column.
Adding project_name to the group by will not work, because grouping by
project_name is not possible (they are different).

Thank you,

Christian



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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Help with query
Следующее
От: "A. Kretschmer"
Дата:
Сообщение: Re: Help with query