ORDER BY with LTREE

From: Axel Straschil <axel(at)straschil(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: ORDER BY with LTREE
Date: 2006-02-17 14:28:13
Message-ID: slrndvbnbs.l6a.axel@m2.sine
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello!

Im working with the ltree [1] datatype and have labels that can not used
directly in ltree and a want to get a tree like strukture ordered by the
labels.

IE, I've got a table

CREATE TABLE t
(
tree LTREE,
label TEXT
);

and data like

tree label
--------------------------
root.1 z
root.2 c
root.2.1 a
root.2.2 b
root.3 i
root.4 f
root.4.1 k
root.4.2 c

I need a VIEW that ordery by "by tree but by label in the same hirachie",
so the output should be

root.2 c
root.2.1 a
root.2.2 b
root.4 f
root.4.2 c
root.4.1 k
root.3 i
root.1 z

Any idea?

Thanks,
AXEL.
[1] http://www.sai.msu.su/~megera/postgres/gist/ltree/

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Henry Ortega 2006-02-17 21:07:28 Given 02-01-2006 to 02-28-2006, output all days.
Previous Message Markus Schaber 2006-02-16 22:41:28 Re: group by complications