Thread: viewing the original order of entered records

viewing the original order of entered records

From
"Sven Van Acker"
Date:

Hi

 

I’ve the following problem:

 

I have a 2-column table with columns “person_id”(int4) and “phase”(text).

 

When I entered the following records in a chronological fashion: <1, “high school”>; <1, “childhood”> and <2, “university”>;

 

 

I requested the following select-statement.

 

SELECT person_id, phase FROM life ORDER BY person_id

 

And found the tuple <1, “childhood”> before the tuple <1, “high school”>.

 

I want to view the chronological order of my entries, but ordered by person_id.

Is this possible in postgresql?

 

Re: viewing the original order of entered records

From
"scott.marlowe"
Date:
On Tue, 10 Jun 2003, Sven Van Acker wrote:

> Hi
>
>
>
> I've the following problem:
>
>
>
> I have a 2-column table with columns "person_id"(int4) and "phase"(text).
>
>
>
> When I entered the following records in a chronological fashion: <1, "high
> school">; <1, "childhood"> and <2, "university">;
>
>
>
>
>
> I requested the following select-statement.
>
>
>
> SELECT person_id, phase FROM life ORDER BY person_id
>
>
>
> And found the tuple <1, "childhood"> before the tuple <1, "high school">.
>
>
>
> I want to view the chronological order of my entries, but ordered by
> person_id.
>
> Is this possible in postgresql?

Yes, just make sure and store a date/time stamp when you insert the
records.  You can use a before trigger to update a time stamp field on
every update of the row.

Note that without a field to "order by" neither postgresql nor any other
database guarantees any particular return order.