Sorting by an arbitrary criterion

Поиск
Список
Период
Сортировка
От Craig James
Тема Sorting by an arbitrary criterion
Дата
Msg-id 4A561A42.1080301@emolecules.com
обсуждение исходный текст
Ответ на Re: Best way to load test a postgresql server  (Greg Smith <gsmith@gregsmith.com>)
Ответы Re: Sorting by an arbitrary criterion  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
Re: Sorting by an arbitrary criterion  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Re: Sorting by an arbitrary criterion  (Alexander Staubo <alex@bengler.no>)
Re: Sorting by an arbitrary criterion  (hubert depesz lubaczewski <depesz@depesz.com>)
Список pgsql-performance
Suppose I have a large table with a small-cardinality CATEGORY column (say, categories 1..5).  I need to sort by an
arbitrary(i.e. user-specified) mapping of CATEGORY, something like this: 

  1 => 'z'
  2 => 'a'
  3 => 'b'
  4 => 'w'
  5 => 'h'

So when I get done, the sort order should be 2,3,5,4,1.

I could create a temporary table with the category-to-key mapping, but is there any way to do this in a single SQL
statement?

Thanks,
Craig

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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Data caching
Следующее
От: Grzegorz Jaśkiewicz
Дата:
Сообщение: Re: Sorting by an arbitrary criterion