Re: ORDER BY what?

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: ORDER BY what?
Дата
Msg-id 20010613095702.B21307@wolff.to
обсуждение исходный текст
Ответ на Re: ORDER BY what?  (Martín Marqués <martin@bugs.unl.edu.ar>)
Список pgsql-sql
On Wed, Jun 13, 2001 at 11:26:54AM +0300,
  Martín Marqués <martin@bugs.unl.edu.ar> wrote:
> On Mié 13 Jun 2001 16:16, Bruno Wolff III wrote:
> > On Tue, Jun 12, 2001 at 03:53:22PM +0300,
> >
> > >
> > > OK, let me give an example:
> > >
> > > select * from tab1 where col1 like '%word%' or col2 like '%word%' and
> > > col3 like '%word%'
> > >
> > > and I want to order by the amopunt of matches that a matching register
> > > has. Something like, if it matches all the ORs, then it should go first,
> > > and if it matches only one of the ORs it should go last.
> > > Or maybe even have several words trying to match one of the columns.
> >
> > You could do this by computing a value based on the number of parts
> > that matched and order by it.
>
> Could you give me a hint on this? Do I have to use PLSQL? Triggers? Something
> else?
>
> Thanks for the responce.

You can use the case statement to check logical tests and return different
values depending on which ones are true. This expression can be used in
the order by clause.

В списке pgsql-sql по дате отправления:

Предыдущее
От: Lamar Owen
Дата:
Сообщение: Re: [GENERAL] Re: ORDER BY what?
Следующее
От: Alessandro Rossi
Дата:
Сообщение: set datestyle to European PROBLEM