No, at least not as you expect it. SQL returns the found records in
random order except for the explicit "order by" clause. So if you want a
chronological order, you have to supply some ordering fields to the
order by clause. This could be achieved easily by normalizing your
table, i.e. create a table like:
create table ages (
age_id smallint primary key,
sort_order smallint,
age_name varchar(100)
);
insert into ages values (1, 10, 'childhood');
insert into ages values (2, 20, 'high school');
insert into ages values (3, 30, 'univesrity');
NOTE: leave gaps in the sort order to accommodate for later insertions.
Then in the original table replace the names with age_id, and use a join
on the 2 tables, sorting by original_table.person_id, ages.sort_order.
HTH,
Csaba.
On Tue, 2003-06-10 at 11:50, 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?
>
>
>