Re: Help with query

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: Help with query
Дата
Msg-id 20060116060856.GA5630@webserv.wug-glas.de
обсуждение исходный текст
Ответ на Re: Help with query  ("Christian Hofmann" <christian.hofmann@gmx.de>)
Ответы Re: Help with query  ("Christian Hofmann" <christian.hofmann@gmx.de>)
Список pgsql-novice
am  15.01.2006, um 20:26:30 +0100 mailte Christian Hofmann folgendes:
> Hello Andreas,

Morning,


>
>
> > 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:

Then you *must* this row added to the 'GROUP BY'. Because you have for
one project_no different project_name, you get for every project_no AND
project_name a max(stamp).


> Do you know how to solve this error? I need this column.

normalize your table.


Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

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

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