From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Jana <jana(dot)vasseru(at)gmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Custom sorting |
Date: | 2009-05-16 19:16:03 |
Message-ID: | 4779.1242501363@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Jana <jana(dot)vasseru(at)gmail(dot)com> writes:
> I would like to make this ordering on database side since there are two
> appliactions which use the data and both would have to reimplement the
> ordering mechanism. I read several articles on custom sorting, which show
> that i can use any function in the ORDER BY clause, however all the
> examples assume only one input value from which the custom function
> genereates some sort of automatically comparable value. However this
> always involves only a single field - which i cannot use since i need two
> rows to say which one is "higher" and "lower" -
Seems like what you need to do is set up this column as a custom
datatype with its own comparison operators. If you make a btree
index opclass for the datatype then ORDER BY will understand that
that's how it should sort the values.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Dallas Morisette | 2009-05-17 00:44:42 | Include result of function call within WHERE clause in results |
Previous Message | Jana | 2009-05-16 17:54:34 | Custom sorting |