Re: Help with query

From: "Christian Hofmann" <christian(dot)hofmann(at)gmx(dot)de>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Help with query
Date: 2006-01-15 19:26:30
Message-ID: 00ba01c61a09$96998870$9000a8c0@taschenrechner
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message A. Kretschmer 2006-01-16 06:08:56 Re: Help with query
Previous Message Andreas Kretschmer 2006-01-15 18:49:39 Re: Help with query