Re: Help with query

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Help with query
Date: 2006-01-16 06:08:56
Message-ID: 20060116060856.GA5630@webserv.wug-glas.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 ===

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Christian Hofmann 2006-01-16 12:56:03 Re: Help with query
Previous Message Christian Hofmann 2006-01-15 19:26:30 Re: Help with query