Re: Custom sorting
От | Tom Lane |
---|---|
Тема | Re: Custom sorting |
Дата | |
Msg-id | 4779.1242501363@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Custom sorting (Jana <jana.vasseru@gmail.com>) |
Список | pgsql-novice |
Jana <jana.vasseru@gmail.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
В списке pgsql-novice по дате отправления: