RE: Records exactly the same.

From: Jeff Eckermann <jeckermann(at)verio(dot)net>
To: Fons Rave <fonzzz(at)xs4all(dot)nl>, pgsql-sql(at)postgresql(dot)org
Subject: RE: Records exactly the same.
Date: 2001-07-20 16:23:32
Message-ID: 08CD1781F85AD4118E0800A0C9B8580B094B51@NEZU
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

If you include "oid" in your GROUP BY clause, you will get each distinct
record.
That will get you by for right now, but Josh's point is correct. You need
some kind of unique key in your table.
But... if you want to see every distinct record: why are you using a GROUP
BY?

> -----Original Message-----
> From: Josh Berkus [SMTP:josh(at)agliodbs(dot)com]
> Sent: Friday, July 20, 2001 9:48 AM
> To: Fons Rave; pgsql-sql(at)postgresql(dot)org
> Subject: Re: Records exactly the same.
>
> Fons,
>
> > I have a file in which there are records with what people have done.
> > In the file
> > are records with name, date, what they have done, time-length, etc.
> > It is
> > possible that there are two records that are exactly the same
> > (somebody has done
> > the same, on the same day for one hour). If I use a SELECT with GROUP
> > on a list
> > with some records that are exactly the same, only ONE of the
> > identicals is
> > shown. But I want to see them all.
>
> Well, there isn't an easy answer for you ... because you've designed
> your database wrong. Records should *never* be the same. That is, ni
> fact, one of the cardinal rules of Relational Database Design.
>
> You need to add an arbitrary primary key (e.g. act_key SERIAL NOT NULL
> PRIMARY KEY) or some other piece of data (such as start_time) to make
> each record unique. Then, by including that unique data in your query,
> you can insure that all records are displayed.
>
> Frankly, I'm surprise that you're not getting errors when you try to
> DELETE a record. This usually happens in tables without a unique key.
>
> It's been my argument for some time that PostgreSQL should require a
> primary key on table creation.
>
> -Josh
>
>
> ______AGLIO DATABASE SOLUTIONS___________________________
> Josh Berkus
> Complete information technology josh(at)agliodbs(dot)com
> and data management solutions (415) 565-7293
> for law firms, small businesses fax 621-2533
> and non-profit organizations. San Francisco << File: >> <<
> File: >> << File: >> << File: ATT09948.txt >>

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2001-07-20 16:56:31 Re: TODO List
Previous Message Jeff Eckermann 2001-07-20 16:12:52 RE: example of [outer] join